• 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: adding PDF annotations to the output of a regular NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding PDF annotations to the output of a regular NSView


  • Subject: Re: adding PDF annotations to the output of a regular NSView
  • From: Martin Wierschin <email@hidden>
  • Date: Wed, 29 Jul 2009 18:26:06 -0700

Hi John,

So the problem is that there doesn't seem to be any way of marrying these two systems together. Ideally there would be some Cocoa method I could call in my NSView's drawRect method to add PDF annotations. But the only solution I see is something like this:

1. Produce raw PDF data from my normal NSView hierarchy.
2. Load that NSView data into a PDFView.
3. Add PDFAnnotations to special regions as desired.
4. Resave the modified PDF data from the PDFView.

I'll start by pointing out that Step 2 is not necessary. Adding annotations in PDF Kit is done at the PDFDocument level. The PDFDocument you will have created from your raw PDF data (from Step 1). The PDFView is strictly for display purposes.


As well then Step 4 more accurately would be "re-save the modified PDFDocument as PDF data."

This seems very inefficient and error prone (eg: mapping coordinates between NSView and PDF page space). Is this really the best option available?

Mapping points from NSView to page space is not an issue. Since the PDF data came from your NSView to begin with you can use the same coordinates you used in the NSView. So for example if the special region was of some bounds (NSRect) in the NSView you can use this same rect to create your PDFAnnotation and add it in PDF Kit.

Thanks very much for your reply. I'm glad to known the process seemed more convoluted than it actually is. I am happily reassured by your advice.


you could replace your NSView with a subclass of PDFPage and display with a PDFView. It depends on your application though ... how much of a kludge this approach would be (you could simply be trading one kludge for another :-)).

Yeah, no thanks :P My view hierarchy is a large network of multi- container NSTextViews and other custom views nested/chained together. Slicing it up for PDFView consumption would be a real nightmare.


Thanks again,

~Martin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >adding PDF annotations to the output of a regular NSView (From: Martin Wierschin <email@hidden>)
 >Re: adding PDF annotations to the output of a regular NSView (From: John Calhoun <email@hidden>)

  • Prev by Date: Re: adding PDF annotations to the output of a regular NSView
  • Next by Date: Binding collection view label through two entities
  • Previous by thread: Re: adding PDF annotations to the output of a regular NSView
  • Next by thread: [NSEvent data1]
  • Index(es):
    • Date
    • Thread