Tinderbox Forum

Create Beautiful PDFs From Your Tinderbox Documents

FWIW, the PDF version of the Tinderbox Help that I help create uses export of styles CSS (including print media CSS) and wkhtmltopdf to generate a PDF with a ToC from the HTML. As the source TBX’s primary role is to generate the HTML needed for the app’s Help, the export to HTML for PDF use is done as a parallel and separate process.

For my part, I insert Latex code directly into my notes, copy and paste it into a Latex editor and Bob’s your uncle (Le tour est joué, in French)!

I haven’t seen the PDF help, only the built-in Mac help (which I think is based off of HTML).

Are you able to share that setup? I’ve used wkhtmltopdf in the past but it always results in tiny text and huge margins. I’d love an HTML-to-PDF method that’s more faithful to the original HTML styling.

Yes, Tinderbox’s Mac Help (as via app’s Help menu) uses HTML (Mac Help’s inner format) which is generated from a (non-public) TBX file.

The PDF can be accessed here: http://www.eastgate.com/download/tbxman720.pdf

wkhtmltopdf v12.4 fixes a number of useful things but has a regression error causing font size issues, so a bit of experimentation is needed to get the correct output font size. The command lines are here.

CSS: the 'manual.css used for the styling of the primary (Help) output (here), then print.css and screen.css (here and here) used only by the for-PDF export.

Okay! Thank you for that. So does the HTML that’s fed into wkhtmltopdf get manual.css + print.css + screen.css ?

Sorry, see here. This page is exported when the TBX exports to HTML but is essentially separate resource. The sed command in the above linked text file is necessary to set in-page links to work correctly (i.e. what were in-doc links in the TBX). If you want access to the Help TBX please contact Eastgate directly as it’s not mine to share.

HTH :slight_smile:

1 Like

It does, thank you!!

Thanks a lot, Mark Anderson.
Might I ask you some questions?

I try to make PDF export using wkthmltopdf ( ver.0.12.4 ) under MacOSX10.11.6 ElCapitan via Terminal.app.

I renamed your print-export-source.html to index.html.
Then my command lines are like under.

wkhtmltopdf --page-size “Letter” --dpi 765 --footer-spacing 4 --print-media-type --footer-center “[page] of [topage]” --footer-font-name “Helvetica Neue” --footer-font-size 11 --footer-line --footer-spacing 5 --header-spacing 5 --header-line --header-center “Tinderbox v7 Manual” --header-font-name “Helvetica Neue” --enable-toc-back-links toc --toc-header-text “Tinderbox v7 Manual - Table of Contents” --toc-text-size-shrink 1 --toc-level-indentation 4em “index.html” “output.pdf”

I get output.pdf almost same as tbxman720.pdf,
( I do not care without graphical contents),
but linking from index to textual explication,
do not work.

How and where should I set your css files in command lines
which put down with print.css screen.css manual.css?

wkhtmltopdf --user-style-sheet print.css screen.css manual.css --page-size “Letter” --dpi 765 --footer-spacing 4 …etc… --toc-header-text “Tinderbox v7 Manual - Table of Contents” --toc-text-size-shrink 1 --toc-level-indentation 4em “index.html” “output.pdf” ??

Is this forms of writing ill-written or crop up ?

Or should I use different kind of command lines?

Yesterday, I got a HELP.tbx from Mr.Mark Bernstein.
I do not know how to make linking from this HELP.TBX to css files.

I look forward to hearing criticize constructively
from you at your earliest convenience.

Thx and regards, WAKAMATSU kunimitsu

I think the problem is that you need to run the sed command line - in the same text file as the wkhtmltopdf command I linked to above. Export the single page HTML, run the sed command line on the HTML page before using wkhtmltopdf.

Why? Because Tinderbox export isn’t designed to export in-page links (i.e. links to #anchors in the same page). My templates produce part of the code, but the regular expression changes, done via sed is needed to complete the task. After the sed command has been run the in-document links will work in HTML and are thus correctly embedded in the PDF at the next stage.

I’m sorry there’s currently no detailed description of this, it was simply something I knocked up to Help Eastgate provide help in PDF form as some users were demanding.

The CSS files are produced as an export from notes in the TBX just like the HTML - look at the TBX and the export seetting for those notes. How the HTML links to CSS is absolutely normal HTML coding. If not sure on this, I’d would look look at:

  1. a basic HTML tutorial on how to write an HTML file that uses an external CSS file.
  2. the Help.tbx’s export templates
  3. a CSS tutorial in the @ directives for defining CSS styles to be used only for certain forms of media (e.g. screen vs. print).

Does this help?

Dear Mark Anderson,

Thanks a lot for your point out.

I will make a thorough review of the points put forth by sed command.

I can find many notes with Outline view.

In Tinderbox HELP.tbx, there is a css note.
Can not I use and rewrite adding with your css files ??
But, unfortunately, I am not in a position to go any further.

And Export note have three type of Template [/Templates/page template children list]

  1. Simple Export [/Templates/page template]
  2. Exporting to HTML
  3. Export Templates (Designators, Placeholders, Macros and Group Designators)
    [/Templates/page template children HTML item]

On the other hand, there are plain notes
i ) Templates [plain]
ii ) css [plain]

I wish I could find informations about how to add [css ]in Template.
How the HTML links to CSS not come to my hand, yet even in whole HELP.tbx.

Should I need to make a folder as a [Templates] , first ?

I have nothing good to report t the moment.

I will put [sed command] in action during this afternoon.

I will present a report on it, later.

I owe you a great debt of gratitude.

Thx and regards, WAKAMATSU kunimitsu

Dear Mark Anderson,
Thanks a lot.
I got it made.(allow for a portion of their export names.)

I derived the meanings of unknown SED words from the WiKi.
It takes a good amount of time to bring understanding.
I am outside the ropes to use SED and wkhtmltopdf.

This time, I have special significance for PDF export with Tinderbox.
Ordinarily interested in LaTeX with Emacs or Spacemacs or Eclipse.
I realize that pdf export.

sed -E ‘s:href=“help[^.]*/([^.]+).html”:href="#x\1":g’ print-export-source.html > index.html

wkhtmltopdf --page-size “Letter” --dpi 765 --footer-spacing 4 --print-media-type --footer-center “[page] of [topage]” --footer-font-name “Helvetica Neue” --footer-font-size 11 --footer-line --footer-spacing 5 --header-spacing 5 --header-line --header-center “Tinderbox v7 Manual” --header-font-name “Helvetica Neue” --enable-toc-back-links toc --toc-header-text “Tinderbox v7 Manual - Table of Contents” --toc-text-size-shrink 1 --toc-level-indentation 4em “index.html” “TinderboxManual v7–2-0-bis.pdf”

Allow me to again thank you for taking advice kindly.

Thx and regards, WAKAMATSU kunimitsu

1 Like

So glad you got there in the end. :grinning:

Okay I’ve done some more digging around documentation and wkhtmltopdf issues, and it seems as though the magic flag combo is: --zoom 2.5 --disable-smart-shrinking. Set the zoom level to whatever looks good to you. No need for the --dpi flag (though maybe that just ends up doing something similar).

I’ll update the document and post in the next couple days, as I greatly prefer the wkhtmltopdf solution so far.

Thanks to @mwra for encouraging me to revisit wkhtmltopdf :slight_smile:

1 Like

Thanks. I think the dpi issue should also be resolved in the next release of `wkhtmltopdf``. The current issue is is a known regression error in the public (Mac) v0.12.4 release (and the project main devs are Win/Linux based).

FWIW, I went with wkhtmltopdf as I wanted a no-cost solution to generating the PDF with links, images and a ToC. I think I looked at pandoc at the time but it either lacked features needed or was too complex to implement.

Thanks for your helpful reply. On inspection, the earlier post was a clear spam post - link was to the same site used in other recent spam cases (whose domain I won’t advertise by repeating it). User & their posts deleted and banned.

Hi everybody.

Could someone kindly provide a how to convert Tinderbox HTML to PDF using the wkhtmltopdf-tool?

How did you @mwra and @WAKAMATSU go about it to achieve and receive a perfect PDF – with working internal Tinderbox-Links – using this very tool.

Looking forward to receiving your kindly shared insight.

Sorry, bit of a brain dump, but sort of time - and real expertise in this. wkhtmltopdf is typical of the tragedy of open source. Lots of free stuff, but just not explained for all but a very narrow audience

FWIW, here is the command line I used to make the PDf of the Tinderbox v7.5 Help file:

sed -E 's:href=\"help[^\.]*\/([^\.]+)\.html\":href=\"#x\1\":g' print-export-source.html > print-export-source-proc.html

wkhtmltopdf --outline --page-size "A4" --footer-spacing 4 --print-media-type --footer-center "[page] of [topage]" --footer-font-name "Helvetica Neue" --footer-font-size 11 --footer-line --footer-spacing 5 --header-spacing 5 --header-line --header-center "Tinderbox v7 Manual" --header-font-name "Helvetica Neue" toc --enable-toc-back-links --toc-header-text "Tinderbox v7 Manual - Table of Contents" --toc-text-size-shrink 1 --toc-level-indentation 4em "print-export-source-proc.html" "Tinderbox v7.5.2 Manual.pdf"

For your purposes the sed bit is probably immaterial and in the second bit you may need to alter file names, etc. But it might help - a bit more than wkhtmltopdf's ‘help’, anyway. :grin:


I meant to add that sadly the Table of contents (TOC) functionality can’t be done via the styled HTML. If you want fine control of the TOC you’ll need to get into XSLT. Good grief, all that ‘just’ to make a PDF. Still, massive kudos to all those who kindly made and shared this code. Otherwise the solution is pay-for and not cheap**.

** I looked at this in some depth a while back. Having chivvied Eastgate into doing HTML help out (and using Tinderbox to do it) I felt bad for those whose can’t understand who to use hypertext and need a long form document to work from, thus the above.


Thanks, @mwra. But I am not even certain yet where to start from. The Terminal?


Otherwise the solution is pay-for and not cheap

Which solution explicitly do you mean?

  1. Sorry, yes. It’s not an app. Download/install the software from wkhtmltopdf and then run the command line in Terminal.

  2. If I recall: Prince - Buy Prince only $495 for a single desktop licence. OK, it’s intended to do far more. But, that’s the irony, if you ‘just’ want to use styled HTML to make a PDF

Fellow forum members feel free to point up better/cheaper solutions. I did the recce on this about 5 years back and things move on…