Internal/Reference Links don't work in PDF

Azat's Avatar

Azat

26 Nov, 2012 06:51 PM

I'm using Print Preview -> Save as PDF. External links are fine, but internal/reference links (something like #partii) are displayed but not clicking on them doesn't make PDF document go to that location.

I'm using following notation

[Part II](#partii)

## Part II {#partii}

or just

## Part II

because marked auto generates IDs for headers.

Is there anyway to make internal link work in PDF?

In Adobe Reader I get the following error when I click on internal links:

  1. Support Staff 1 Posted by Brett on 26 Nov, 2012 07:03 PM

    Brett's Avatar

    It's a limitation of the webkit print system. I've long been looking for a way around it, but have nothing short of generating documents entirely outside of webkit (Pandoc, wkpdf), but then I can't maintain much of the formatting. It's a quandry.

  2. 2 Posted by Azat on 28 Nov, 2012 07:59 PM

    Azat's Avatar

    Brett,

    What would be the best, i.e., fastest and most accurate in terms of preserving formatting, way of converting markdown/HTML to PDF? Pandoc+Latex or something else?

  3. Support Staff 3 Posted by Brett on 28 Nov, 2012 08:02 PM

    Brett's Avatar

    Take a look at wkpdf and wkhtmltopdf. Combined with your preferred Markdown processor, they can do a pretty decent job, though I can't remember offhand if both deal with internal links the way you need. If I find a better solution, I'll definitely post it.

  4. 4 Posted by Azat on 28 Nov, 2012 08:11 PM

    Azat's Avatar

    Maybe it's possible to include reference links in auto-generated TOC which Marked app already does using page numbers in PDF, e.g.,

    <A HREF="http://www.example.com/myfile.pdf#page=4">

    Would be nice to have this feature!

  5. 5 Posted by otto.hammersmit... on 11 Jan, 2013 02:49 AM

    otto.hammersmith's Avatar

    Same problem.

    It wouldn't be an issue, except the "Save PDF" saves as a single page. Which can get giant if it's a long document.

    If that could be paginated, that would be swell.

    P.S. OpenID login is busted on the support site. And I think the captcha ate my comment the first time.

  6. Support Staff 6 Posted by Brett on 11 Jan, 2013 03:04 AM

    Brett's Avatar

    You can paginate by using Print -> Save as PDF. Internal links don't work in _any_ webkit pdf output at this point. It's something I'm hoping Apple will fix in the near future.

  7. 7 Posted by Ivan Wong on 09 Apr, 2013 02:37 AM

    Ivan Wong's Avatar

    Has anyone any workaround to share to enable internal linking?

    At the moment I'm resorting to inserting this in my css to make the output not appear to be a link, but nothing more frustrating that hovering and not being able to click in a pdf :)

    @media print { /* print only styles. Keep it clean */ a { color: black; } }

  8. 8 Posted by Azat Mardanov on 09 Apr, 2013 02:43 AM

    Azat Mardanov's Avatar

    Hi Ivan,

    I solved the problem by moving the Markdown -> PDF conversion away from Marked app to LeanPub platform. They use Latex and bunch of other stuff.

    --
    Azat Mardanov
    azat.co (http://azat.co)

  9. 9 Posted by Ivan Wong on 09 Apr, 2013 03:48 AM

    Ivan Wong's Avatar

    Hi Azat,

    Thanks for the tip - am checking out their platform now and they apparently use markdown (vs multimarkdown) so some marked features don't seem to be available.

    My markdown syntax for links also appears to be incorrect as it is not being converted.

    Could you please share your syntax for links and images in LeanPub?

    Thanks,
    Ivan

  10. 10 Posted by Azat Mardanov on 09 Apr, 2013 04:13 AM

    Azat Mardanov's Avatar

    Google for leanpub manual.

  11. 11 Posted by Ivan Wong on 09 Apr, 2013 04:23 AM

    Ivan Wong's Avatar

    Oops should have RTFM first...

    Thanks again.

  12. Brett closed this discussion on 25 Apr, 2013 08:48 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