Re: Printing - Why are my PDF files so big?
Re: Printing - Why are my PDF files so big?
- Subject: Re: Printing - Why are my PDF files so big?
- From: Scott Thompson <email@hidden>
- Date: Tue, 11 Jul 2006 16:25:26 -0500
On Jul 11, 2006, at 1:59 PM, douglas a. welton wrote:
I have a custom NSView that "displays" like a photographic contact
sheet - it prints a collection of images in grid. Within my view's
-drawRect: method, I use an NSImageCell to do my drawing - for each
image, I determine where it belongs on the page, then send a -
drawWithFrame:inView: method to the NSImageCell. I print the view
by simply sending a -print: message.
The problem I have is related to the size of PDF file I get as a
result of printing. If I print a contact sheet using the 37 images
in my test directory (which have a combined size of 6.3 Megabytes),
then tell the standard NSPrintPanel to save the file as a PDF, I
get a PDF file that is over 162Mbs...
If I tell the NSPrintPanel to compress my PDF, I get a file of only
14 Mbs.
I've looked over the Cocoa Printing documentation and a few entries
in the archives (most notable "Ridiculously Enormous PDFs and
Printing"), but I didn't see an obvious (to me) way of telling the
Mac OS X print architecture to compress/optimize the size of my PDF/
printing.
Does such an option exist? If so, would someone please send me a
pointer to it. If not, what other options do I have for making a
smaller PDF file from my printing?
I imagine that your images on disk are probably compressed (JPEG or
PNG). However, when they are added to the printed stream, they
probably go out as raw images.
If your images are PNG or JPEG, one thing you might try is avoiding
NSImage and using CG directly. Create the CGImage you want to draw
using CGImageCreateWithJPEGDataProvider or
CGImageCreateWithPNGDataProvider and then draw them using
CGContextDrawImage.
(I suppose that even if your image files are not in PNG or JPEG, you
could re-compress the images as PNG or JPEG and try using those)
My hope is that the printing architecture will be clever enough to
pick up the compressed stream from the data source and will spool
that into the PDF.
Scott
_______________________________________________
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