preserving links and cross-references in PDF output

Mathew's Avatar

Mathew

25 Oct, 2011 11:53 AM

I'm having a problem preserving links and cross-references in my PDF output. No problem at all with the HTML.

Specifically the links, cross-refs show up as blue (my link highlighting color).

I'm making the PDF by going to Print, then using "Save as PDF" option.

Don't know if it's relevant, but attached is a screenshot of my Behavior prefs.

  1. Support Staff 1 Posted by Brett on 25 Oct, 2011 01:04 PM

    Brett's Avatar

    I'm afraid I don't understand the question. They're showing up as blue and you don't want them to? Or they're showing up as blue and they don't work?

  2. 2 Posted by Mathew on 25 Oct, 2011 01:05 PM

    Mathew's Avatar

    My bad. Links showing up as blue is fine. Problem is they don't work as active links in PDFs. Is there some trick to make them "active" links in PDFs?

  3. Support Staff 3 Posted by Brett on 25 Oct, 2011 02:36 PM

    Brett's Avatar

    So we're talking about both internal and external links, right? I'll do some testing, but it may come back to the way that WebKit handles PDF output. I'm not certain at this point that I'll have a fix, but I will definitely look into it. I know PDF output is an important facet of handling Markdown files for many users.

  4. 4 Posted by Mathew on 25 Oct, 2011 02:58 PM

    Mathew's Avatar

    Yes, both internal and external links are not active in a final PDF.

    Here's what's strange to me: if I put in a raw http address that will not be colored, but it will be an active link in the final PDF. But if I put in nicely formatted multimarkdown code for http (or cross refs) then they'll be colored but not be active.

  5. Support Staff 5 Posted by Brett on 27 Oct, 2011 02:06 PM

    Brett's Avatar

    Like I said, this is going to be a WebKit issue that may be out of my hands, but I'll definitely look into it. Extensively, actually, as preserving links would be a major benefit if I can make it work.

  6. 6 Posted by Mathew Mitchell on 27 Oct, 2011 03:23 PM

    Mathew Mitchell's Avatar

    Brett: Thanks for looking into this. I fully understand there may be no
    solution, but if anyone can figure out a way to solve this it's you! Just
    glad you're willing to explore the possibilities.

    - Mathew

  7. Support Staff 7 Posted by Brett on 02 Nov, 2011 02:14 PM

    Brett's Avatar

    It's definitely WebKit. Even Safari can't save a PDF and preserve anything other than links on text that actually looks like a url (same as Marked). The only app on OS X that seems to be able to create a PDF that Preview can read with proper links is Pages, but it uses a completely different rendering engine.

    Because this is an important feature, I'm working on building my own rendering code instead of using the content of the WebKit preview, but it will have the drawback of not being able to fully render the output the way the preview shows it. I have not found a way around that yet.

    By the way, opening one of the PDF's output by Marked in Adobe Reader and saving as an Adobe PDF seems to restore the link functionality. Preview can't do it, but for some reason Acrobat can read the links properly in some cases.

  8. 8 Posted by Mathew Mitchell on 02 Nov, 2011 03:32 PM

    Mathew Mitchell's Avatar

    Brett: Thanks for the update. I tested with Acrobat Pro but no luck with links
    preserved, even within Acrobat.

    I don't know how big an issue it will be if output does not render same as preview.
    I guess it will depend on how much discrepancy there is. I appreciate the problem
    is complex though!

    Many thanks for continuing to look into this issue.

    - Mathew

  9. 9 Posted by THC on 03 Nov, 2011 02:48 PM

    THC's Avatar

    My workaround for the problem is to save the doc as html and use htmldoc command:

    htmldoc -f cv.pdf --header "" --footer "" --webpage cv.html --linkcolor navy --linkstyle plain

    Hopefully, you'd integrating the functionality into Marked. Thanks.

  10. 10 Posted by Eric Vitiello on 13 Jan, 2012 06:39 PM

    Eric Vitiello's Avatar

    Sounds very odd that text that is a URL comes through as clickable, but markdown-formatted URLs do not. Are you creating the links differently?

    If this is indeed a Webkit problem, please file a bug report with apple (http://bugreport.apple.com) and send me the Radar Id if you don't mind :)

  11. Support Staff 11 Posted by Brett on 13 Jan, 2012 06:45 PM

    Brett's Avatar

    Try it in Safari, you'll get the same results. I'll file a bug report once I'm back from CES.

    -Brett

  12. 12 Posted by Eric Vitiello on 13 Jan, 2012 06:57 PM

    Eric Vitiello's Avatar

    Cool. have a nice time :) I'll see what I can do about getting it fixed.

  13. 13 Posted by Eric Vitiello on 14 Jan, 2012 12:43 AM

    Eric Vitiello's Avatar
  14. Support Staff 14 Posted by Brett on 16 Jan, 2012 08:35 PM

    Brett's Avatar

    Hopefully this fix will be applied soon to the version of webkit embedded by Xcode. As soon as the fix is available to third-party applications, it will be included in Marked.

  15. Support Staff 15 Posted by Brett on 27 Feb, 2012 04:04 AM

    Brett's Avatar

    I just tested this against the Safari 5.2 framework and it preserves external links perfectly. Internal (cross-reference) links aren't followed, but I'll see if there's a workaround for that. I don't know the public release schedule for 5.2, but it shouldn't be far off.

  16. 16 Posted by Mathew Mitchell on 27 Feb, 2012 01:43 PM

    Mathew Mitchell's Avatar

    This is great news re: external links! Thanks for the update,

    Mathew

  17. 17 Posted by Gunther Groenew... on 21 Mar, 2012 12:10 AM

    Gunther Groenewege's Avatar

    I noticed that when I add a @media print section to my stylesheet and define the color of the a tag within this section, the external links keep working after a print as PDF.

  18. Brett closed this discussion on 26 Aug, 2012 08:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac