Relative links in a PDF

Steven Fisher's Avatar

Steven Fisher

23 Apr, 2014 04:23 PM

I would like an option when I print a PDF to specify that the relative links in my document should be resolved to absolute links relative to something on the web.

The reason for this is that I usually write developer documentation in markdown for publishing on github. However, if I'm sending a PDF instead the "see also" links should resolve relative to the hosted location, rather than the location on the hard drive of the user I'm emailing the PDF to.

  1. Support Staff 1 Posted by Brett on 23 Apr, 2014 04:27 PM

    Brett's Avatar

    I don't think this is really possible with the way that webkit generates
    PDFs. I would have to rewrite all of the links in the document prior to
    exporting the PDF, anyway...

  2. 2 Posted by Steven Fisher on 23 Apr, 2014 04:33 PM

    Steven Fisher's Avatar


    There's also the base tag. Inserting that into the head of the document would set the links. You'd have to use an absolute URL for the CSS and anything else in the document, though.

  3. Support Staff 3 Posted by Brett on 23 Apr, 2014 04:46 PM

    Brett's Avatar

    Not for PDF output, I don't think. I already set a base tag via JS when
    the document loads.

  4. 4 Posted by Steven Fisher on 23 Apr, 2014 04:47 PM

    Steven Fisher's Avatar

    Yeah, I assume you'd have to actually mutate the HTML for it to take for the PDF export. Javascript's probably never going to run on the PDF path.

    Anyway, have a great day. :)

  5. Support Staff 5 Posted by Brett on 23 Apr, 2014 04:49 PM

    Brett's Avatar

    The PDF prints from the current contents of the web view, so JS run
    prior to the print action does stick. The base url just doesn't seem to
    affect PDF output.

  6. 6 Posted by Paul Solt on 27 Sep, 2017 02:07 PM

    Paul Solt's Avatar

    Is this still a known issue of PDF exporting to create cross-reference links in multi-markdown?

    Any way to get this working with the PDF export, without losing my custom header/footer?

    Create Links to Generic Headers Using a Cross-Reference

        ### Overview [MultiMarkdownOverview] ##

    Create Links to Headers

        ## Section 1 [sect1] ##
        ... text content
        [Jump to Section 1][sect1]
  7. Support Staff 7 Posted by Brett on 27 Sep, 2017 04:10 PM

    Brett's Avatar

    Hi Paul,

    I'm afraid it's still an issue, yes. There's no workaround within Marked, but it can be set up with Pandoc or wkhtml2pdf. Pandoc for sure can handle headers and footers, I'm not sure about wkhtml2pdf. Neither are super convenient, though, apologies.

    I'm still hoping Apple will just hand me a solution in an Xcode update, but it hasn't happened yet. I'm currently working on the RTF export, but once that's fully production-ready, I'll be focusing on building my own PDF output rather than using the PDF print system in WebKit.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? 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