Paginated PDF from NSView saved in memory
Paginated PDF from NSView saved in memory
- Subject: Paginated PDF from NSView saved in memory
- From: Dragan Milić <email@hidden>
- Date: Tue, 30 Dec 2008 13:07:07 +0100
Hello all,
Is there any way of saving paginated multipage PDF created with
NSPrintOperation into memory? What I need to do is to create multiple
PDF out of the NSTextView and put it into the memory buffer. The PDF
document should be properly paginated, and NSTextView can hold RTFD
attributed string with embedded images, so if there are some images
wider then the width of the chosen PDF page, they should be scaled
properly to fit. Also, if an image is to be cropped in two subsequent
pages, the proper vertical pagination will make sure that it will be
drawn on the next page, thus leaving the bottom part of the previous
page empty (I hope you get the picture what I'm trying to describe).
Using NSPrintOperation in conjunction with NSPrintInfo enables very
easy pagination settings with [printInfo
setHorizontalPagination:NSFitPagination] and printInfo
setVerticalPagination:NSAutoPagination]. But I can's save created PDF
into memory, only as a file by setting [[printInfo dictionary]
setObject:NSPrintSaveJob forKey:NSPrintJobDisposition] and [[printInfo
dictionary] setObject:@"path/to/file" forKey:NSPrintSavePath];
Using CGContextRef, CGPDFContextCreate(), and drawing cached portion
of the NSTextView for the particular page into that CGContextRef
between CGPDFContextBeginPage() and CGPDFContextEndPage() creates
multipage PDF in memory, but without proper pagination nor cropping
and I couldn't find any easy way of doing it.
I even read documentation on Core Printing API, hoping it provides
saving the print job into the memory, but it seems such functionality
doesn't exist.
So any ideas? I can get the NSGraphicsContext used by
NSPrintOperation. Is there anything I can do with it to capture
printed data into memory? Or does anyone know of any easy way of
handling pagination (including image resizing) without using
NSPrintInfo? Or any other idea?
Milke
_______________________________________________
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