I am trying to create and save a PDF document where the contents of
the PDF file is derived from a passed-in NSString. The method in
question is in an application without a graphical component, so a
solution using NSView's dataWithPDFInsideRect: seem to be out, as
does using NSPrintOperation and its
printOperationWithView:printInfo: method as this also takes an
NSView as an argument.
I have also looked at PDFKit's PDFDocument intWithData:, but as I
only have a string and this method requires PDF data encapsulated
in an NSData object, this isn't helping much (passing in the string
contents as a NSData object drew a blank)!
Does anyone have any ideas as to where I can direct my efforts, or
have I overlooked something in the methods I mentioned earlier?
You can use Core Graphics to do this directly. The general technique
would be to take the NSString, build a Cocoa text system from it
There is one trick to all this that is particularly insidious. When
you create the NSGraphicsContext, it will keep a reference to the PDF
context through the autorelease pool. The PDF context MUST be
destroyed before the PDF it creates will be written out fully. So
the easiest way to handle it is to create teh NSGraphicsContext in an
evnironment with your own autorelease pool so you can control it's
lifetype more precisely.
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