Re: PDFMarkupAnnotations not showing when drawing PDFPage
Re: PDFMarkupAnnotations not showing when drawing PDFPage
- Subject: Re: PDFMarkupAnnotations not showing when drawing PDFPage
- From: Antonio Nunes <email@hidden>
- Date: Thu, 15 Feb 2007 23:36:36 +0000
On Feb 15, 2007, at 9:28 PM, John Calhoun wrote:
So, the Highlight annotation draws by stroking a line between pairs
of the quad points. (If you number them 0 to 3 in a sort of Z
pattern, then a line running from the midpoint between 0 and 3 and
the midpoint between 1 and 3 is stroked.) The stroke line width is
relative to the distance between these pairs of points. So, to
highlight as you describe an entire page, would likely end up with
a stroke of some 700 or so points. This could be the problem —
I've never pushed CG to stroke a line that thick. Or the code to
determine the line may be failing for such extreme cases....
I'm not sure I understand the Z pattern. According to the docs the
quadriliteral points are ordered counterclockwise at the lower-left
corner of the current page. I make that:
-----
|3 2|
|0 1|
-----
If you mean that a line is drawn from the midpoint between 0 and 3 to
the midpoint between 1 and 2, that I would understand. And also that
the width of the stroke would be relative to the distance within (not
between) the pairs, ie the distance between 0 and 3 and between 1 and
2. Is this correct?
Try making the highlight smaller for a start and see if you can get
a small highlight. That would eliminate color and a few other
possibilities. If it is indeed size that is the issue - you could
grow it until it fails. That might illuminating. But generally,
you probably would be better to have multiple highlights (one per
line of text) anyway. I would pursue this approach anyway. Figure
out how to break up a page into individual lines and then either
create individual Highlight annotations for each line of text or
create a single Highlight annotation with multiple groups of quad
points.
Okay, no need for highlights that size anyway, I just thought it was
an easy way to get some bounds and see if anything appeared. So I
changed the code to the following:
PDFPage *page = [trackedObject pdfPage];
PDFSelection *selection = [page selectionForLineAtPoint:NSMakePoint
(100, 100)];
if (selection) {
NSRect bounds = [selection boundsForPage:page];
PDFAnnotationMarkup *markup = [[[PDFAnnotationMarkup alloc]
initWithBounds:bounds] autorelease];
[markup setMarkupType:kPDFMarkupTypeHighlight];
[page addAnnotation:markup];
[page setDisplaysAnnotations:YES];
[[currentDocument layoutView] setNeedsDisplay:YES];
} else { ...
Easy enough and a selection is returned hence the if-block is
executed. The debugger shows the markup thus:
(gdb) po markup
Type: 'Highlight', Bounds: (90, 99) [146, 11]
...so this is a single line. Nothing too big. The rest also checks
okay in the debugger. The page lists the annotation. But I still do
not see the markup. I tried a strikeout style too, but that did not a
difference make.
António Nunes
-----------------------------------------------------------
And could you keep your heart in wonder
at the daily miracles of your life,
your pain would not seem less wondrous
than your joy.
--Kahlil Gibran
-----------------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden