Save to PDF and Links to Tiddlers

Links to tiddlers, or internal links, are managed by JavaScript in TiddlyWiki. However, there are methods to control the href generation when exporting to static pages.

The process for controlling href generation is detailed in https://tiddlywiki.com/#LinkWidget.

My inquiry is: when exporting two or three tiddlers to a PDF using the browser’s print and save to PDF functionality (no Node.JS), how can the href generation be controlled to ensure the internal links function correctly?

Ref:

As far as I know that’s not possible at the moment, since browser printing does not use specific TW templates. Creating static pages does use specific templates, that are responsible to convert href for static pages.

I think you should post this at GitHub too and mention @jeremyruston here or @jermolene at Gighub.

I utilize a new page layout to print or save to PDF through the browser’s print to PDF functionality. This enables the use of a new $:/core/ui/ViewTemplate. Is it possible for this to control the href generation, similar to exporting to a page?

Just a thought: maybe your printing viewtemplate could define a custom <$link> widget?

Fred

There are Configuration variables, but I don’t know how they can be used with save to PDF? Yes, I am thinking to use custom view template when print!

I had some kind of result with this code:

!! Normal tiddlywiki link to tiddler:

[[HelloThere]]

!! Tweaked link to tiddler:

<$let tv-filter-export-link="[[https://www.duckduckgo.com]]">

[[HelloThere]]

</$let>

Paste it in a new tiddler on tiddlywiki.com. Inside TW, both links point to HelloThere, but when exported to PDF, second link goes to www.duckduckgo.com

Fred

Very interesting. Of note is that in TW, the location in the status bar (I’m on Chrome/Windows at the moment) is duckduckgo, even though it actually simply opens the tiddler.

Same thing here, Firefox on linux.
I guess it’s a security related feature, the browser shows the “real” target of the link (even though js treatment of TW links actually redirects to the target tiddler instead of the href).

Fred

  • Open TiddlyWiki v5.3.6 — a non-linear personal web notebook
  • Create a tiddler tagged with $:/tags/Global with the following content:
    \define tv-wikilink-template() static/$uri_doubleencoded$.html
    
  • Save and close.
  • Print the open tiddlers in your story river (for example, on Windows press Ctrl+P) and choose “Save to PDF” (NOT “Print to PDF”).
  • Open the resulting PDF in a browser—every wikilink will work and point to static pages of TiddlyWiki.
2 Likes