Re: REPOST: Lossless PDF scaling
Re: REPOST: Lossless PDF scaling
- Subject: Re: REPOST: Lossless PDF scaling
- From: Christian Brunschen <email@hidden>
- Date: Mon, 6 May 2002 16:27:29 +0100
On Monday, May 6, 2002, at 03:59 PM, Kirk Kerekes wrote:
Subject: Lossless PDF scaling
Explanation by example:
I have a pdf image composed as a 11x17 inch page, in an NSData, say.
I want to convert it into a pdf image that is internally scaled
losslessly to a 8.5x11 page.
"Losslessly" means that a 72dpi bitmap embedded in the original 11x17
image will draw as a 144dpi bitmap in the 8.5x11 image. It means that
all of the non-bitmap drawing operations in the pdf will be
appropriately scaled to fit in the new page size, and will continue to
be "resolution independent"
.
I have tried every juggle with NSImage and NSImageRep and NSPDFImageRep
et al that I can think of. I currently get (relative to the above
example) one of the following results:
1) a 72dpi bitmap of the entire page, scaled or unscaled.
2) a 144dpi bitmap of the entire page, scaled.
3) The original pdf, at the original size.
4) Various interesting reports from the Console crash log.
I have tried many things that, based on the documentation, ought to
work. But if they did, you wouldn't be reading this now.
I know it can be done, because I can take the 11x17 pdf, drop it onto
Preview, do a print-to-Preview, and what comes out is exactly what I
want to get.
Wisdom, anyone?
Have you investigated NSView:s '- dataWithPDFInRect:(NSRect)rect' method?
The approach would be:
1) Load your original PDF into an NSImage
2) Create an NSView - possibly an NSImageView, or a custom view of your
own - set up to draw _and print_ at the _target_ size you want (let's
call this the 'targetView')
3) Then, NSData *scaledPDFData = [targetView
dataWithPDFInRect:[targetView bounds]];
should basically give you the PDF representing the data inside that
rect, ie, the scaled original PDF.
Best wishes,
// Christian Brunschen
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.