Re: Problem printing offscreen PDFViews
Re: Problem printing offscreen PDFViews
- Subject: Re: Problem printing offscreen PDFViews
- From: Waldo Lee Sharvey <email@hidden>
- Date: Thu, 14 Jan 2010 09:29:40 -0500
Tried that already, and it only lead to other weird stuff. Consider
this: If PDFView obeyed all of the normal laws Cocoa printing,
wouldn't PDFView's printWithInfo:autoRotate: be unnecessary?
Not that this really matters anymore, since I ended up taking the long
route and writing a custom NSView subclass with all the necessary
pagination/drawing methods implemented and using a NSPDFImageRep. I'm
now just curious as to why it didn't work.
-- Ilan
On Wed, Jan 13, 2010 at 7:26 PM, Kyle Sluder <email@hidden> wrote:
> Why are you using a different pattern for printing your PDF view than
> you are using for your regular view? Use NSPrintOpertaion and
> -setShowPanels: as described in
> http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Printing/Tasks/UsingPrintPanel.html
>
> --Kyle Sluder
>
> On Wed, Jan 13, 2010 at 8:35 AM, Waldo Lee Sharvey
> <email@hidden> wrote:
>> I have a situation where I want to print a multi-page PDF. While I
>> could use the PDFKit utility classes and/or quartz functions to get
>> the information to manually write drawing/pagination code for a NSView
>> subclass, I had thought that quicker alternative would be to create an
>> off-screen PDFView and tell it to print itself. When I tried this
>> solution, the print dialog didn't go away, all of the print settings
>> controls on the right half of the print dialog disappeared, and the
>> application froze.
>>
>> I then wrote a tiny test application with the following method that
>> illustrates the problem. When the test program is compiled without the
>> USE_PDF_VIEW preprocessor macro defined, the blank view displays fine.
>> If USE_PDF_VIEW is defined, the document doesn't print, most of the
>> print dialog controls disappear, and the app freezes. While I have
>> other ways of accomplishing my goal, I'm curious as to why this
>> shortcut doesn't work. Is there something about Cocoa drawing I still
>> don't understand? Am I banging into Apple Voodoo Magic(tm) behind the
>> scenes that makes PDFView behave in a completely different way than
>> other NSViews?
>>
>> - (void)printMyStuff:(id)sender {
>>
>> NSPrintInfo *currInfo = [NSPrintInfo sharedPrintInfo];
>>
>> #ifdef USE_PDF_VIEW
>>
>>
>> PDFView *pdfView = [[PDFView alloc] init];
>> PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL
>> fileURLWithPath:@"/Users/wls/Documents/my_document.pdf"]];
>> [pdfView setDocument: pdfDoc];
>> [pdfView printWithInfo:currInfo autoRotate:YES];
>>
>>
>> #else
>>
>> NSView *myView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 500)];
>> NSPrintOperation *myop = [NSPrintOperation
>> printOperationWithView:myView printInfo:currInfo];
>> [myop runOperation];
>>
>>
>> #endif
>>
>> }
>> _______________________________________________
>>
>> 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
>>
>
_______________________________________________
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