Re: PDF zooming
Re: PDF zooming
- Subject: Re: PDF zooming
- From: "R. Scott Thompson" <email@hidden>
- Date: Fri, 24 Sep 2004 14:05:06 -0500
On Sep 22, 2004, at 11:45 PM, Tim Conkling wrote:
Cool -- thanks for the tip. I'm new to Cocoa and CoreGraphics (coming
from Carbon QuickDraw land), so I didn't think to read the docs on CG
(except for the CGPDF stuff, for which there are no Cocoa classes).
Out of curiosity, how would this be done with an NSImage (how do I get
the PDF into the NSImage)?
Sorry... I got sidetracked and forgot to respnd.
The tricky part with NSImage is the fact that the system will cache a
bitmap of the PDF for you the first time it draw it. That means that
if you draw it at one size, and then try to redraw it at another size
later, what you will get is a scaled bitmap instead of the nice smooth
PDF you want.
To create an NSImage from a PDF you can simply use any of the NSImage
init methods that take files as parameters or data:
initWithData:
initWithContentsOfFile:
initWithContentsOfURL:
initByReferencingFile:
initByReferencingURL:
etc...
Testing Emperically what you get back is an NSImage with a single
NSPDFImageRep until you draw the image the first time. After that the
NSPDFImageRep will be replaced with an NSCachedImageRep.
To draw the image at 200% you could use
[myImage setScalesWhenResized: true]
[myImage setSize: <size that represents image at 200%>]
then draw the image as usual.
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
_______________________________________________
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