tclpdf

tclpdf
Login

tclpdf

tclpdf - PDF generation for Tcl


Synopsis

Create PDF documents from Tcl: pages, graphics, embedded fonts, images, tables and electronic invoices. A pure Tcl package - no compiler, no binary extension, no Tk.

Beyond the usual page, text and graphics work it does two things a PDF writer often leaves out: general file attachments, and form XObjects that store a drawing once and place it as often as wanted. A document is a TclOO object, every command takes Tcl-style -options, and the topical modules are loaded on first use - a caller who writes text never loads the image code.

Everything listed here is built and tested. Measured against the page count of its chapters that covers roughly a third of ISO 32000-1 - and the missing two thirds are almost entirely what a reader of foreign PDFs needs rather than a writer, plus encryption and form fields.


Dependencies

Nothing else is needed: zlib is a command built into Tcl, not a package, and Tk is never loaded - not for colour names, not for images.


Documentation

The package ships that manual page, tclpdf(n), covering every command.

The source archive adds the test suite and 36 examples, which between them write 38 documents: shapes, colour, text layout, attachments, forms, diagonal stamps, flowing text and text along a path, soft hyphens and leader rows, extending the package from outside, font embedding in three formats, kerning, ligatures, five writing systems, missing glyphs, images, gradients, SVG, labels inside a drawing, barcodes, three kinds of table, two ZUGFeRD invoices, a PDF/A certificate, two tagged documents, an accessible one and a PDF/UA-2 guide, and a navigation demo. Each one is a readable script of its own and says in its header what it is for.

Build them all at once and look at the result:

make examples

That runs every example into examples/out - one PDF each, three for the writing-systems example, which writes one file per face. make clean removes the directory again. A single example also runs on its own and takes the output path as its argument:

tclsh examples/04.01-table-basics.tcl mytable.pdf

See Also


Copyright (C) 2026 Alexander Schoepe, Bochum, DE

Tcl package: MIT license. That covers everything the package installs: the Tcl modules, pkgIndex.tcl and the sRGB ICC profile, which is a runtime part because its bytes end up inside every PDF/A document.

No font is part of the package. The faces under examples/assets/fonts are there so that the tests and the examples have something to embed, and they travel in the source archive alone - make install installs no font, and the binary archives contain none. They are third-party work under their own terms: DejaVu under the Bitstream Vera licence, and Roboto, Bitcount Prop Single and Niconne under the SIL Open Font License 1.1. Whether you may embed a font into a PDF that tclpdf writes is a question for that font's licence, not for this one.