Tiddly2PDF Release

Tiddly2PDF is a plugin that allows for seamless conversion from wikis to fully customized PDFs. It is designed to allow wikis serving as documentation or journals to be exported into a more standard document format.

This is my first plugin, so I hope I didn’t mess anything up too badly :slight_smile:

This is the v0.1.1 release, otherwise known as very early alpha. The basic functionality all works, but expect some bugs. Currently, issues when formatting templates and configs can cause js errors if filled out wrong.

I hope some people end up testing it out, as I would love to get some feedback, feature requests, and bug reports for me to use to improve the plugin.

Warning: Sadly due to the libraries the plugin runs on the total size ends up being 2MB, and there is not much I can do to shrink it.

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

7 Likes

Great plugin! Thank you for sharing @GameDungeon

I add it to my list of favorites plugin as it is very handy!

Few features may be added in your long term run:

  • The footer and header may read from tiddler itself (e.g. recognize currentTiddler and then can read or access to header/footer field) this way you can have different header or footer on different page (like books)
  • A better name for exported pdf can be used or it can be a user input (now it is file.pdf)
  • A plain css may be better option versus a JSON one
  • The size of $:/plugins/GameDungeon/Tiddly2PDF/ExportAsPDFWidget.js is ~2MB, may be it can be reduced by some minimization techniques.
1 Like

Thanks a lot :slight_smile:

While I plan to add a lot of information from the tiddlers to it (which should be all you need), it is limited to the HTML, so you can’t do full Wikitext stuff.

I can’t believe I didn’t think of that. That’s an easy addition, so expect it next version.

Due to the way that PDF Make works, this is sadly not an option.

That is minimized. It’s really just a massive lib.

1 Like

Hi @GameDungeon I have tried it out and it is great. I have two questions and or improvements;

It seems great at automagically page breaking even a single long tiddler. But the solution prints all tiddlers tagged PDF.

  • I have wikis responsible for generating more than one pdf. Could we have a view toolbar button to only print the current tiddler, which itself may be a compound tiddler containing many tiddlers content?
    • this basic feature would be great, but then ultimately if individual tiddlers could specify different templates and settings that would be even more powerful.
  • Have an example tiddler containing multiple paragraphs, in html <p></p> tags generated by tiddlywiki. I would like to add page-break=avoid on each paragraph, but not sure the best way to do this just for the printing. I may wish to do this to other elements as well such as <ul> <ol> <tabel> etc…

The default font of pdfmake does not support Chinese

    let dd: docDefinition = {
            header: headerFunction,
            footer: footerFunction,
            background: backgroundFunction,
            content: [],
            images: {},
            styles: this.getPDFStyles()
        };

Maybe add a config font like the example below;

pdfMake.addFont('Arial.ttf', 'Arial', 'normal');

const docDefinition = {
  content: [
    { text: 'Hello world!', font: 'Arial' }
  ]
};

I was looking at implementing font selection, and then I noticed that the example code included the entire 700kb font lib. After handling that properly, I managed to shrink the plugin down to 1.2MB, which is a considerable improvement.

2 Likes

Version 0.1.2 is now out.

New Features include:

  • Shinked down to 1.5MB (I had to add some fonts back to get everything working)
  • File names are now selectable
  • Custom Fonts can now be uploaded and used. (This was the big thing)
  • Minor bug fixes and opened an issue to get one resolved.

What next? The ability to have multiple docs and to be able to select different templates and settings for individual tiddlers. Additionally, lots more vars for the templates to choose from.

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

1 Like

Version 0.1.3 is now out.

New Features include:

  • Style Changes
  • Added additional built-in styles
  • Added Page fields

Looking for feedback on improving the default styling of the pdfs for a better out-of-the-box look, and suggestions for additional built-in styles, page fields, and template variables.

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

1 Like

Small warning - It looks like I forgot to update the default font setting when changing which font came built-in. If the export button is not working make sure to check the right font is selected.

Thanks for working on this @GameDungeon,

As I raised before I would appreciate if we can PDF the current tiddler, because I have tiddlers that I have built from multiple other tiddlers, that I would like to print on their own, rather via a tag (PDF) in your example. It will mean I have to set when to page break etc… but I am fine with that.

  • perhaps a separate ViewToolbar button?

That’s on the to-do list, I just haven’t gotten around to it yet.

The tiddly in the name does not correspond to the pdf word, perhaps tiddler2pdf would be better?

The general idea is it converts a TiddlyWiki to a PDF, though the original name was TiddlyPDF, it was suggested to change it to this. I’m going to say it’s probably a bit late to change the name now.

1 Like

Version 0.1.4 is now out.

New Features include:

  • Added $pdf-subtitle page field and template var
  • Added support for non-standard image types.
  • Added support for the default highlighter

Soon:

  • A sub-plugin to allow highlight.js support in the PDFs

Still looking for any feedback on improving the default styling of the pdfs for a better out-of-the-box look, and suggestions for additional built-in styles, page fields, and template variables.

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

3 Likes

Version 0.1.5 is now out.

New Features include:

  • Breaking: Style tiddlers are now based in CSS instead of JSON (Only a small subset of features is currently supported, as well as non-standard attributes.)
  • A guide for setting up highlight.js support.

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

3 Likes

Version 0.1.6 is now out.

I took a break for a long while, sorry for the wait.

New Features include:

  • Export single tiddlers as PDFs (@TW_Tones)
  • Style Changes
  • Various fixes I forgot in the 9 month break

Github: GitHub - GameDungeon/Tiddly2PDF
Docs: Tiddly2PDF Docs
Download: Releases · GameDungeon/Tiddly2PDF · GitHub

3 Likes

Beautiful @GameDungeon I cant believe how fast it is and thank you very much for the tiddler only conversion. This should be important to a lot of users such as teachers/trainers/presentors, authors and publishers, anyone who wants to create content and publish it as a static document, a PDF.

Why am I so excited?

If you know tiddlywiki, or even html we can construct tiddlers with advanced content including pulling information from tiddlywiki as a database, the tiddlers are great to view online, but now we can quickly create a PDF for printing or distribution.

Questions

  1. @GameDungeon as the plugin currently stands, how are page breaks handled on single and story tiddlers?, what is the best way to force a break?
  2. Currently clicking a pdf button opens the new PDF in a new tab, this is nice and helpful, but could we have a method to instead save as a file via the download mechanism, the export selector? perhaps also using ctrl-click on the current button?

It currently just breaks when it runs out of room on a page. It should be pretty simple to add an html tag to force a page break, so I should be able to do that soon. It is a bit crude, but right now you could just add whitespace to force it to break.

It should be possible for me to allow you to directly save the file. If I find time I might add it to an export. It isn’t a high priority feature for me currently, as you can always save the file from the new tab page.

Knowing this helps, so I don’t look for something that is not there.

I have a macro to insert a page break in CSS, when I find it I may post here for others to use.

It could be as simple as introducing a modifier key on the button, and generate a different link to cause a download. I am only suggesting it as a possible enhancement. No pressure at all, thanks for your effort so far, this is very useful :nerd_face:

FYI:
With a direct download mechanism it would be possible to enhance it to save the PDF using the title of the tiddler, or wiki, making manual bulk export quick and easy.

  • But I understand you have achieved this through a different but very quick approach.

Love your work :clap:

Hello @GameDungeon,

nice work, thanks. :clap: :+1:

How to make text-align: justify?

Feature requests:
add configure options to $:/core/ui/ControlPanel/Settings for

  • make an option to set font-size
    eg: 90% → will affect all predefinded ($:/plugins/GameDungeon/Tiddly2PDF/pdfstyles/defaultStyles) or make each of them configurable
  • make an option to set the margins

Thanks, Stefan