• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PDFMarkupAnnotations not showing when drawing PDFPage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PDFMarkupAnnotations not showing when drawing PDFPage


  • Subject: Re: PDFMarkupAnnotations not showing when drawing PDFPage
  • From: John Calhoun <email@hidden>
  • Date: Mon, 19 Feb 2007 14:45:53 -0800

On Feb 17, 2007, at 5:06 AM, Antonio Nunes wrote:
This call is charmingly functional when drawing to screen, but doesn't get called when printing.

Check the annotations -[shouldPrint] — this may be off by default.

- (void) drawWithBox: (CGPDFBox) box inContext: (CGContextRef) context
{
	:
   // Let's draw yellow for now
   float yellow[4] = { 1.0, 1.0, 0.0, 1.0 };
   CGContextSetFillColor(context, yellow);
	:
}

I wouldn't be surprised if the were circumstances that could break this code. I also totally ignore the PDF box in this test code.

The code looks fine to my eyes. Rather than hard-coding the color you can call -[self color] from your annotation subclass and then get the RGB components from that.


Strikeout and Underline can just draw with a standard copy or sourceOver transfer modes since they don't care about obscuring the underlying content.

You will get burned on pages with rotation or non-zero crop/media box. Leopard added a nice convenience method your annotation could call:

- (void) [PDFPage transformContextForBox: (PDFDisplayBox) box];

For Tiger you'll have to implement something similar. The code might look like this:

- (void) transformContextForPage: (PDFPage *) page forBox: (PDFDisplayBox) box
{
NSAffineTransform *transform;
NSRect boxRect;
int rotation;

boxRect = [page boundsForBox: box];

transform = [NSAffineTransform transform];

rotation = [page rotation];
switch (rotation)
{
case 90:
[transform rotateByDegrees: -90];
[transform translateXBy: -boxRect.size.width yBy: 0.0];
break;

case 180:
[transform rotateByDegrees: 180];
[transform translateXBy: -boxRect.size.width yBy: - boxRect.size.height];
break;

case 270:
[transform rotateByDegrees: 90];
[transform translateXBy: 0.0 yBy: -boxRect.size.height];
break;
}

[transform translateXBy: -boxRect.origin.x yBy: -boxRect.origin.y];

[transform concat];
}


john calhoun—

_______________________________________________

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


References: 
 >PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (CORRECTION) (From: John Calhoun <email@hidden>)
 >Re: PDFMarkupAnnotations not showing when drawing PDFPage (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: Custom Shadow on an NSWindow
  • Next by Date: Re: Custom Shadow on an NSWindow
  • Previous by thread: Re: PDFMarkupAnnotations not showing when drawing PDFPage
  • Next by thread: Re: PDFMarkupAnnotations not showing when drawing PDFPage
  • Index(es):
    • Date
    • Thread