On 27 Feb 2014, at 9:31 pm, Leonardo <[email protected]> wrote:
> I draw an NSImage within an NSView scaling its size in order to fill the > image within the view bounds. The image is larger than the NSView's bounds, > but on the display it looks well clipped to those bounds. > > Since the image's NSView is a subView of the page's NSView, I create a PDF > saving that page's NSView > > [pageView dataWithPDFInsideRect:pageRect]; > > and I get a pdf file. Anyway, when I inspect the pdf file with Acrobat, I > clearly see that the image hasn't been cropped. As I see from the blue > rectangle around the visible small image, the whole original and larger > image has been embedded within the pdf document. > In facts if I Control-Click-Edit the image on the pdf, I get the original > whole image. So the pdf file size results bigger than what it would really > be. I don't get this trouble when saving the page to a TIFF or any other > raster image file (with NSBitmapImageRep -> CGImage -> > displayRectIgnoringOpacity -> CGImageDestinationFinalize). This is exactly what you'd expect. Core Graphics basically *is* a PDF. So when you draw an image into a view that is clipped, all you're doing is setting a clipping path and drawing an image. The PDF faithfully records that. When you create a different image that is clipped to the smaller area, then that's what is recorded. > My question: > Do you know an option, any API, to clip the image to its NSView's frame on > the pdf, as it properly looks on the display? Or should I clip the image by > my own code? When you know how it works, the question becomes moot. The short answer is 'no', there's no API. You have to resample/crop the image as you need, or accept the larger filesize for the convenience that you get from the simple API. --Graham _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
