resizing PDF obtained from dataWithPDFInsideRect:
resizing PDF obtained from dataWithPDFInsideRect:
- Subject: resizing PDF obtained from dataWithPDFInsideRect:
- From: Chinh Nguyen <email@hidden>
- Date: Thu, 19 Nov 2009 16:37:20 -0600
I've got an image that's generated using a large integer coordinate
space. When it's drawn to the screen, its coordinates are converted
to screen coordinates. Unfortunately, the screen coordinates are
assumed to be integers and it's not a simple fix to use floats (the
code is common to Mac, Windows, and X Windows). The code will be
eventually rewritten, just not anytime soon.
The conversion to screen coordinates is causing stair stepping in
connected lines and other oddities when exporting to PDF. As a
temporary solution until the code is rewritten, I've created a
subclass of my view that's sized at the large coordinate space's
dimensions specifically for rendering the image to PDF. However, I
can't seem to resize the PDF data down to the more manageable screen
view's dimensions when saving to disk. I've tried creating an
NSPDFImageRep from the PDF data and resizing it but it has no effect
on the saved to disk image (I guess setSize: does not affect the
original data). What I end up with is a PDF file with large
dimensions that overwhelms whatever application I'm placing it into.
What I ended up doing is creating an NSView subclass that simply draws
the PDF at the size I want and returns the PDF data from that. This
works but is there a better way of resizing the dimensions of PDF data
or is the size the size that it's generated at and there's no changing
it?
Also, I allow the user to export the image as a bitmap and even
override the dimensions. I create an NSImage from the PDF data,
resize the NSImage, then save the TIFF representation to the bitmap
format I want. This works in Leopard but no longer works in Snow
Leopard. I read the tech note about changes to NSImage and caching
but I had no luck with the different caching methods. I ended up
creating an NSImage at the desired size, locking the focus, drawing
the PDF data at the desired size, unlocking the focus, then saving the
TIFF representation. Is there a better way?
And finally, is there a way to change the resolution of a bitmap from
72dpi to say 300dpi? My users want to be able to specify the
dimensions of the exported bitmap in inches and the resolution. They
want to be able to place their 1800 pixel wide TIFF file into Word and
it show up 6 inches wide (@ 300dpi) instead of 25 inches wide (@
72dpi). Not a huge deal because I still recommend our users use PDF
but some of them have legacy apps that don't support PDF. The example
I was able to find on this created a new NSBitmapImageRep and copied
the image data into it and then set the size.
TIA.
-Chinh Nguyen
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