![]() |
PDF export: pitfalls and known problems | ![]() |
The statements marked (checked) were verified on 2026-10-06 by exporting small documents with a build which has the native renderer (PDF_RENDERER) and inspecting the result with mutool. Most problems are filed as issue #302 of mgubi/texmacs.
Check which renderer wrote a file. A build without PDF_RENDERER, or with the preference native pdf off, still exports PDF, through PostScript and Ghostscript: links and outlines then come from the pdfmarks of the PostScript renderer, the fonts and the text layer are those of Ghostscript, and the file has /Producer (GPL Ghostscript …) and the file name as its title. mutool info file.pdf shows the producer. The CMake build enables the renderer for Qt without MuPDF; the autotools build enables it by default, but only with Qt or Cocoa, zlib, libpng and FreeType. The other ports (Vue, SDL, Qtwk, X11) write PDF with MuPDF when they have it, and through Ghostscript otherwise.
texmacs -c loses the hlinks (checked). The conversion from the command line exports the buffer right after loading it, before it has been typeset on screen, so display_links finds no links for accessible loci, and only references and other generated loci become links. Exporting a buffer which is open in a window works.
Math letters are lost in the text layer (checked). Glyphs of the TeX math fonts are mapped to their position in the font instead of a Unicode character, so \(x^2 + \alpha\) is copied as x2 + . and \(\alpha\) in a bold heading as a. The text fonts are fixed by pull request #157 in wip_fixes.
Backslashes in bookmarks (checked). Section titles are escaped for a literal string and then written as a hex string, so f(x) appears as f\(x\) in the outline. Non-ASCII titles are right.
Parentheses in URLs (checked). The destination of a link is written into /URI (…) without escaping: an unbalanced ) makes the annotation unreadable.
The PDF version needs Ghostscript. Without USE_GS, the preference texmacs->pdf:version is ignored and the version is 1.4, so the /ActualText spans of ligatures (1.5) are never written. With it, the default is 1.4 too.
One annotation per word. Links spanning several words, and links which wrap, give one annotation per box; viewers show them as separate links (see the FIXME in
boxes.cpp:833
).
Relative links are not resolved. A link to other.tm becomes /URI (other.tm), which viewers resolve against the location of the PDF file, if at all.
The author may be the user's name. When the document has no author, get_metadata runs finger ‘whoami‘ (outside Windows, when the commands exist) and puts the full name of the user in the PDF file.
Empty bitmap glyphs (issue #146, item 3). A Type 3 glyph without ink is written as an inline image of width 0, which is not valid PDF. This is fixed on the wip_opentype branch.
Dead code. draw_bitmap_glyph and the table pdf_glyphs are never filled: nothing calls draw_bitmap_glyph, and bitmap glyphs go through Type 3 fonts.