On Jun 20, 2008, at 12:53 PM, John Calhoun wrote:


On Jun 20, 2008, at 5:21 AM, Adam R. Maxwell wrote:
If you want to draw in memory, I think you have to drop down to Quartz; using PDFKit would likely be easier, but it looks like you can only specify a Quartz filter when saving to a file?.

I think there may be some confusion with regards to drawing....

Antonio is correct that PDFPage has a -[drawWithBox:] method that is used not simply for displaying to screen but also for rendering into a PDF context for saving to file as well. So, you can still use PDFPage, override -[drawWithBox:] in an app that has no intention of displaying the PDF to screen.

The saving method is in PDFDocument. When called it walks through each PDFPage in the document and calls it to render into a PDF context. (Printing within PDF Kit does something similar, BTW.) Optionally too, you can pass a QuartzFilter to the save method in PDFDocument and get, for example, grayscale output.

You can also do something similar in Quartz with CGPDFDocumentRefs and CGPDFPageRefs. The QuartzFilter stuff should work for CGContexts as well.

There is I think a perception that PDF Kit is only for displaying PDF's and I like to try to dispell that when I can. :-)

I appreciated Antonio's (and your) reminder :). If I understand correctly, the OP could create a PDF context with kCGPDFXDestinationOutputProfile set to a grayscale profile, set it as the current context with [NSGraphicsContext setCurrentContext:], then draw each PDFPage into it. Would you still have to use CGContextBeginPage/CGContextEndPage in that case, or is there an easier way to draw all pages of a PDFDocument into a given context? There's an obvious advantage in using PDFKit if you're saving to disk, but I'm curious to know if there's a distinct advantage in using it to draw to memory. Subclassing PDFPage apparently requires 10.5, also, unless I'm missing something.

thanks,
adam
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to