Re: PDFDocument and PDFPage
Re: PDFDocument and PDFPage
- Subject: Re: PDFDocument and PDFPage
- From: Fabio Mancinelli <email@hidden>
- Date: Mon, 02 Oct 2006 12:48:28 +0200
Antonio Nunes wrote:
To retain the original quality of the image use its setDataRetained
method with a value of YES before scaling it the first time, e.g.
immediately after creating the NSImage object.
Thank you. It works fine with this setting.
I am not aware of a way to directly scale a PDFPage. You can scale the
drawing of the page, as I wrote previously, by using an NSAffine
transform. I suppose you could render the PDF offscreen and grab that
representation into an image. Others may be able to provide a better
solution to this.
Currently what I do is the following:
PDFPage *currentPage = [PDFDocument pageAtIndex:pageNumber];
NSData *data = [currentPage dataRepresentation];
NSImage *image = [[NSImage alloc] initWithData:data];
and then, in the drawRect of the view I do:
[image setScalesWhenResized:YES];
NSRect bounds = [self bounds];
[image setSize:bounds.size];
[image drawInRect:drawingRect fromRect:imageRect
operation:NSCompositeCopy fraction:1.0];
I haven't found in the PDFPage class any instance method that could be
used to draw somewhere the page. There is this drawWithBox method but it
doesn't take any "destination".
Is there a particular reason you can't just render the PDF directly to
your view? The project I'm working on doesn't use PDFView either: it
uses transforms to size and place the PDFPages in the view.
I can do it.
The problem I have is... how exactly? :)
Thank you again for your help.
Fabio
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden