Re: NSAttributedText initWithHTML: can you preserving html links
Re: NSAttributedText initWithHTML: can you preserving html links
- Subject: Re: NSAttributedText initWithHTML: can you preserving html links
- From: Nicko van Someren <email@hidden>
- Date: Mon, 24 Apr 2006 13:14:07 +0100
On 24 Apr 2006, at 12:40, minapre999 wrote:
I have some code to convert html into pdf (code below). To do this
I create an NSAttributedString object, using initWithHTML:, put the
attributed string into a NSTextView, then use print objects to
print the pdf to a file. I want to preserve the html links of the
original file, as links in the final pdf document.
This isn't going to work because the printing process does not
"print" the links, since it is only concerned with the appearance of
the text.
The initWithHTML: method does not appear to convert the links into
thean NSLinkAttributeName in the NSAttributedString
That should work; it works for me in a quick test here and it is the
standard way to get links into things like the "About App..." dialogue.
(even if it did, I'm not sure if saving the text view as pdf would
preserve it).
Does anyone know if cocoa can convert html to pdf, and preserve the
links?
The only way I can think of doing this, and it's sort of ugly, is to
make up the PDF file as you do at the moment and then load it back
into an PDFDocument using PKDKit. Then you can extract the text,
match up the text against your NSAttributedString, locate the link
attributes and then attach PDFAnnotationLink objects to the matching
texts. You can then save it back out with the link annotations.
It's yucky, but it might work...
Nicko
_______________________________________________
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