PDF export: Make links within same document functional

+1 please

Chromium’s Skia/PDF m113, the thing that gives “Save to PDF” in the print page dialog of the browser, exports HTML to PDF correctly, with functioning internal links.

In Obsidian v1.3.3 accessing process.versions in the Dev Tools (Ctrl+Shift+I on Windows) shows Chrome at version 112.0.5615.183 and Electron 24.3.1 (latest stable)

So I guess it’s not a question of the Obsidian team updating Electron.

This bug probably involves some post-processing of the note’s generated preview markup which must have some custom solution to internal links. That has to be turned back into real HTML anchor links, so that printToPDF can do the PDF conversion correctly.

Is this hard to do, would it introduce breaking changes or something?

1 Like

+1, i would love to have this feature. But i wonder if there aren’t any workarounds for now? like a third party plugin for exporting maybe?

+1 (making it to 5 characters)

I fully support this request.
Is it already in the feature request list?

Have a nice day

I agree! It is one of my highly requested features for Obsidian.

But just a thought:

Perhaps it is not since it kind of reduces the need for the users to pay for the subscription that allows them to collaborate with each other.

If you can simply print the .pdf and the .pdf works almost exactly like the note and then you use that file for documentation for your co-workers, perhaps you won’t need to pay for that subscription.

For workarounds there’s:

  • Enhancing Export plugin. For me it doesn’t work well actually :confused:
  • Incomplete: I wrote this script to convert Obsidian to Latex. It still needs a few improvements, but for simple cases it works. And yeah, it does maintain the internal links :blush:

+1 for a this feature request, I have a plethora of reasons to export .md docs to pdf and it’s a bit disappointing that none of my tables of content function when I do so. Any one have a work-around for now?

thx, for any help, or the feature implementation, if it’s possible…

Great big +1 from me! I’ve just wasted a day trying to write a Python script to fix internal links in Obsidian exported PDF files. PDF is such a cursed format :imp:

It’s a strange problem. Footnotes in the exported PDF work - along with the link by a footnote to take you back to the main text where the footnote marker is - but # links made by hand don’t. I wonder what’s happening during the export process that means footnote links work, but # links don’t?

+1. Agreed to have internal links “active” in pdf export. That would really be a great improvement to the “export to pdf” function.

It looks like this might be implemented in v1.3.6 according to @WhiteNoise

No, that is different feature request about the PDF reader in obsidian.

1 Like

Oh fiddlesticks! You are correct. Bummer.

I’d assume that it is fairly popular.

I have shown Obsidian to my PhD friends, in order to be used for more than note-taking (like writing reports and guide-files).

One of the first things that people ask me is “does it export those notes in .pdf properly?”

For me, properly requires internal links and outline on pdf.


For workarounds there’s:

  • Enhancing Export plugin. For me it doesn’t work well actually :confused:
  • Close to complete: I wrote this script to convert Obsidian to Latex. It still needs a few improvements, but for simple cases it works. And yeah, it does maintain the internal links, as well as the outline :blush:
1 Like

would love to see this implemented in Obsidian, very useful feature, I’m surprised it’s been years since this was requested and not yet implemented. I totally understand the complexities of a roadmap and the prioritization of other requests by the developers.

I would love to see this as well but I fear it’s is not easy to implement, since obsidian seems to use the print function of the chromium browser it is built on and redirects the output into a pdf.

Currently pandoc with crossref seems the only option to generate a pdf with working links. Unfortunately pandoc doesn’t support obsidian wikilinks. But there is a plugin (I think it is called link converter) to convert obsidian links into standard markdown links that can be handled by pandoc.

There are two plugins as far as I know that integrate pandoc into obsidian. One of these is obsidian-enhancing-export. But its not easy to setup a working pandoc environment. In particular you need also e latex environment since pandoc cannot translate markdown directly to pdf but first convert it to latex which is then converted to pdf using pdflatex or xelatex.

For those who dare there is a tutorial how to setup obsidian for academic writing which also covers pandoc and additional plugins

+1. Fiddling with pdf export as well (wanting to export a whole folder of notes as a single ebook in epub / pdf / html).

1 Like

I’ve been thinking about this, and I think I’ve worked out a possible solution, based on the fact that external (http://) links work.

  1. Just before a PDF is exported, rewrite all in-document links to dummy external links, e.g a link to [[#Some heading]] gets rewritten to [Some heading](http://dummy.url/#Some%20heading)
  2. Export PDF using Obsidian’s built-in PDF export
  3. Use PDF-LIB to rewrite the dummy links in the exported PDF back to in-document links

I think it’d be possible to write an Obsidian plugin to do this, either by hooking up a notification to when PDFs get exported, or triggering PDF export from the plugin itself.

Based on my limited understanding of the PDF format, it might be quite hard to do 3), since I believe PDF internal links are based on actual locations in the document (e.g ‘a rectangle halfway down the page on page 23’) rather than named headers (eg ‘#Some heading’). Should be doable though, even if it’s just by searching through the document looking for the location of ‘Some heading’ in the correct style or something.

Anyway. My time for actual coding is very limited right now (I’m trying to finish a big writing project), but I might have a crack at it when that project is done.