Re: -[PDFView drawPage:] and Printing
Re: -[PDFView drawPage:] and Printing
- Subject: Re: -[PDFView drawPage:] and Printing
- From: Antonio Nunes <email@hidden>
- Date: Tue, 10 Feb 2009 15:20:25 +0100
Forgot to include the list when I sent this, so, for the benefit of
the archives:
On 9 Feb 2009, at 22:28, Kyle Sluder wrote:
I'm overriding -drawPage: in a PDFView subclass with the intent of
layering two PDFs on top of each other. It works great on screen, but
when I attempt to print the document, PDFKit just prints the document
PDFView rather than using my -drawPage: method. I've tried -[PDFView
print:], -[[PDFView documentView] print:], and -[PDFView
printWithInfo:autoRotate:]. All of them just pass the source PDF
right through.
Am I going to have to generate a new PDFDocument by hand?
I don't know if there is any way to get the PDFView to do what you
want, but, if you are targeting Leopard and onwards, an alternative
(and IMO better) approach would be to subclass PDFDocument and to make
your subclass create PDFPages of your PDFPage subclass, where you can
layer a page on top of the source page in the drawWithBox method. So,
you wouldn't need to create a new PDF document at print time, you'd
just have a different setup.
Lookup - (Class)pageClass in PDFDocument, and - (void)drawWithBox:
(PDFDisplayBox)box in PDFPage.
the drawWithBox method in a 'MYPDFPage' class would be something
roughly like:
- (void)drawWithBox:(PDFDisplayBox)box
{
[super drawWithBox:box]; // Draw source page
...
// Obtain page to superimpose
...
[superimposedPage drawWithBox:box]; // Draw superimposed page
}
pageClass in your 'MYPDFDocument' class would be something like:
- (Class)pageClass
{
// Instruct MYPDFDocument to create MYPDFPage objects instead of the
default PDFPage objects.
return [MYPDFPage class];
}
-António
----------------------------------------------------
There is a world of difference between
searching for happiness and choosing
to be happy.
----------------------------------------------------
_______________________________________________
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