# How to export a gantt chart in pdf or png format using taskjuggler and/or org-mode

I managed to get taskjuggler up and running along emacs/org-mode. After reading the manual entries here and here I can export my project into html but I cannot export the Gantt chart into pdf, as hinted at the end of this section.

The workflow seems to be 1) export the project into a .tjp file and then 2) use the GUI to do File->Print. However, the version that I am using tj3 (TaskJuggler) 3.7.1 does not have a GUI as far as I know. I have tried to look for a command that would allow me to export the tjp file into pdf, e.g., export but without luck.

I am looking for a solution that allows me to obtain a Gantt Chart in a format which can be inserted in a document, although I prefer pdf format and to be able to do it from inside emacs org-mode. Thank you in advance.

Update

Apparently the standard way to achieve this is to export the html into pdf using a web browser or packages available in linux distros, e.g. wkhtmltoimage and wkhtmltopdf. However, the main problems that I find with these solutions are that 1) for long projects they partially hide the project and show a frozen scrollbar (major issue), and 2) they do not isolate the gantt chart (minor)

I'm no expert by any means but one partial solution is proposed here:

Basically they say to print the page from a web browser while visiting the .html file generated by org-taskjuggler-export-process-and-open.

However, at least on Firefox the generated pdf skips the colors and arrows, rendering the result kind of useless. And the general workarounds seem unnecessarily complicated.

I'm using tj3 same as you, and man tj3 does not even mention the word pdf.

I hope they come up with a less hacky solution.

• These are some relevant options indeed, thanks. I had no good results when printing from within firefox. The other software mentioned in the post, wkhtmltoimage and wkhtmltopdf, worked better but 1) for long projects they partially hide the project and show a frozen scrollbar (major issue), and 2) they do not isolate the gantt chart (minor) Jul 22 '21 at 7:51

The process is:

• export the Org mode file (say foo.org) to a tjp file (foo.tjp).
• process the tjp file with tj3: tj3 foo.tjp
• view the resulting HTML (Plan.html) file with a browser (both Firefox and Chrome worked for me).
• Print from the browser to PDF, but make sure to first open More settings and select the Background graphics (Chrome) or Print backgrounds (Firefox) option. Then click Save.

It's probably possible to do the last two steps through a CLI command, so that it could be done from inside Emacs, but I don't know how to do that off the top of my head.

EDIT: I don't know about Firefox but Chrome can print to PDF from the command line with this bash command:

/opt/google/chrome/chrome --headless --print-to-pdf file://\$PWD/Plan.html


You might have to change the path to the chrome` executable.