Re: NSAttributedString and PDF
Re: NSAttributedString and PDF
- Subject: Re: NSAttributedString and PDF
- From: Douglas Davidson <email@hidden>
- Date: Mon, 29 Jan 2007 09:46:35 -0800
On Jan 27, 2007, at 4:26 AM, Julio Cesar Silva dos Santos wrote:
I would like to know if there is a way of saving an
NSAttributedString into PDF format. This NSAttributedString comes
from an NSTextView and I know that Views have the
dataWithPDFInsideRect: method but when I save it to a PDF file it
becomes weird (no margins, for example).
My code so far:
PDFDocument * myPDF = [[PDFDocument alloc] initWithData:[myTextView
dataWithPDFInsideRect:[myTextView bounds]]];
[myPDF writeToFile:[@"~/Documents" stringByExpandingTildeInPath]];
If I get the data of the NSAttributedString (using dataFromRange:)
the PDF document is not created because it lacks the '%PDF' tag.
Am I getting the right approach? Any suggestion will be welcomed.
Writing to a PDF is essentially equivalent to printing, so you should
probably look in that direction. You might look at the TextEdit
sources, for example, for the handling of print info.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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