1

Has anyone put together a plugin or tool for exporting a Tiddlywiki to pdf?

blueberryfields
  • 45,910
  • 28
  • 89
  • 168

4 Answers4

2

No, there isn't.

As a workaround, I write or find a decent printable stylesheet, then print to PDF.

blueberryfields
  • 45,910
  • 28
  • 89
  • 168
ken
  • 1,067
  • 9
  • 14
0

Why not select the target tiddler to "Open in new window", and print it to PDF with any installed PDF printer?

Hangchen Yu
  • 325
  • 3
  • 12
0

To accomplish this I used a tool to convert HTML to PDF. These steps are a bit long but well worth it. Once you've got it working it is easily repeated.

  1. In each tiddler that I want in my PDF, I mark with a specific tag; I used TableOfContents.

  2. In each tiddler that is marked with this tag, I added an order field--to be used to define the order of tiddlers to appear in the PDF.

  3. Ensure your HTML headers are properly defined for the document. I think tiddler titles use <h2>, so properly defining subheadings using <h3><h4> etc will ensure, if you want, a nice auto-generated Table of Contents in your PDF.

  4. If you want each tiddler to start on a new page (in the PDF), we need to add this HTML to the end of each tiddler:

<div style = "display:block; clear:both; page-break-after:always;"></div>

  1. With a completed TiddlyWiki document export the tiddlers to a single HTML file--this will be used to generate a PDF document. To export, go to the AdvancedSearch, select the Filter tab. In the search textbox enter your filter criteria--for me that was:

    [tag[TableOfContents]sort[order]]

You'll see, immediately, on-screen a list of the tiddlers the system found based on that criteria. Then click on the Export icon and select Static HTML.

  1. Optionally, but I think it's a great idea, manually create a cover page (in your favorite editor)--this will be a single HTML file to act as the cover page in the PDF document; call it cover.html. More on this later.

  2. Download and install wkhtmltopdf (command-line tool to generate PDF from an HTML file).

    https://wkhtmltopdf.org/downloads.html

  3. Learn and get familiar with the wkhtmltopdf command line syntax. There are numerous features here so the command you end up with maybe lengthy. Use wkhtmltopdf /? to view general help, then wkhtmltopdf --extended-help to view details (well worth the read).

  4. Generate a PDF document. At the command prompt navigate to the folder where your TiddlyWiki document is located. Here is a list of my favorite command-line switches. My app is installed in C:\Program Files..., so my command line starts with that...

"c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"

Add this switch for a header on the left:

--header-left "My document title"

For a header on the right:

--header-right "v1.0.0.1"

Font size of header:

--header-font-size 8

Display a line below the header:

--header-line

Spacing between header and content in mm (default 0):

--header-spacing 5

A left-footer ([section] is replaced with the name of the current section:

--footer-left "[section]"

A centered footer:

--footer-center "Page [page] of [topage]"

Footer font size:

--footer-font-size 8

Footer spacing:

--footer-spacing 5

If you want titles to hyperlink (in the PDF) to go back to the TOC:

--enable-toc-back-links

Make sure no background images get printed:

--no-background

I added special styles in the TiddlyWiki document for print media--to hide tags and clean up the spacing. Then I used this switch to ensure print media is used:

--print-media-type

Being in North America I want letter-size pages; I think the default is A4:

-s Letter

IMPORTANT--give the tool access to local files, otherwise your images will be missing in the PDF:

--enable-local-file-access

Use this if you want to have a cover page (see step 6 above):

cover "cover.htm"

And use this if you want a TOC automatically generated. Without a cover page, the TOC will be your first page, so create a cover page:

toc

After the toc identify your exported tiddler HTML file as input to the tool:

tiddlers.html

And, the final argument on the command line is the output PDF file name:

MyDocument.pdf

clsturgeon
  • 192
  • 2
  • 11
0

Export the tid to html. Then in the terminal, issue:

html2pdf $myTid.html $myTid.pdf

$myTid is only a var and can be any name :)

Achylles
  • 31
  • 4