Hi António,

Thanks for the interesting suggestion and link.

Using your suggestion, I added this to drawWithBox: in my subclassed PDFPage:

NSLog(@"drawing to screen: %@", [[NSGraphicsContext currentContext] isDrawingToScreen] ? @"YES" : @"NO");

Drawing to the screen returns YES. However, just opening PDFView's NSPrintPanel returns NO - that is before the user chooses to print or cancel, etc.

I'll keep testing it and to see if I can get it to work. Perhaps I should check isDrawingToScreen in a subclass of PDFView rather than PDFPage.

I don't mind if the destination is a PDF or EPS so that part is easy. The numbers would still increment if output was generated.

Thanks,
Will


On Jun 13, 2008, at 11:40 PM, Antonio Nunes wrote:

On 14 Jun 2008, at 05:28, Wilhelm Phillips wrote:

In order to achieve the desired result I subclassed PDFPage from PDFKit to draw the appropriate numbers and PDFDocument to apply that pageClass to any pages that I add to myPDFDocument.

An alternative may be to try to leverage NSGrahpicContext's isDrawingToScreen. A return value of NO may mean that the drawing destination is a printer, but the destination may also be a PDF or EPS file, so you need to set up a way to make sure you're not drawing to a PDF or EPS file when you call it. Once you have that set up you can add some code to your PDFPage subclass's drawWithBox: method that sets a flag to indicate the page was printed and/or its number was used.

The following link may have some more useful info:
http://frameworker.wordpress.com/2008/05/16/a-glimpse-into-pdfkit/

António

--------------------------------------------
I try to take one day at a time, but sometimes, several days attack me all at once!
--------------------------------------------



_______________________________________________

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