Package: pdfje
pdf·je[🔉PDF·yuh] (noun) Dutch for ‘small PDF’Write beautiful PDFs in declarative Python.(Currently in active development. Leave a⭐️on GitHub if you’re interested how this develops!)FeaturesWhat makespdfjestand out from the other PDF writers? Here are some of the highlights:🧩 Declarative APIIn most PDF writers, you create empty objects and
then mutate them with methods likeaddText(),
all while changing the state with methods likesetFont().Pdfjeis different. You describe the document you want to write,
and pdfje takes care of the details. No state to manage, no mutations.
This makes your code easier to reuse and reason about.frompdfjeimportDocumentDocument("Olá Mundo!").write("hello.pdf")Seethe tutorialfor a complete overview of features, including:Styling text including font, size, and colorAutomatic layout of text into one or more columnsBuiltin and embedded fontsDrawing basic shapesSee theroadmapfor supported features.📖 Decent typographyLegibility counts. Good typography is a key part of that.Pdfjesupports several features to make your documents look great:Visually pleasing linebreaks, using thesame basic principles as LaTeXAutomatickerningusing available font metricsAvoidingwidows and orphansby moving
lines between columns or pages.🎈 Small footprintThe PDF format supports many features, but most of the time you only need a few.
Why install many dependencies — just to write a simple document?
Not only ispdfjepure-Python, it allows you to
install only the dependencies you need.pipinstallpdfje# no dependenciespipinstallpdfje[fonts,hyphens]# embedded fonts and improved hyphenationRoadmapPdfjeis still in active development,
so it is not yet feature-complete.
Until the 1.0 version, the API may change with minor releases.Features:✅ = implemented, 🚧 = planned, ❌ = not plannedTypesetting✅ Automatic kerning✅ Wrapping text into lines, columns, and pages✅ Page sizes✅ Centering text✅ Justification✅ Hyphenation✅ Move lines between columns/pages to avoid widows/orphans✅ Tex-style line breaking🚧 Headings (which stick to their paragraphs)🚧 Indentation🚧 Keeping layout elements together🚧 Loosening paragraphs to avoid orphans/widows🚧 Broader unicode support in text wrappingDrawing operations✅ Lines✅ Rectangles✅ Circles, ellipses🚧 Arbitrary paths, fills, and strokesText styling✅ Font and size✅ Embedded fonts✅ Colors✅ Bold, italic🚧 Underline and strikethrough🚧 Superscript and subscript❌ Complex fill patterns🚧 Images🚧 Bookmarks and links🚧 Tables🚧 Bullet/numbered lists🚧 Inline markup with Markdown (Commonmark/MyST)❌ Emoji❌ Tables of contents❌ Forms❌ AnnotationsVersioning and compatibility policyPdfjefollows semantic versioning.
Until the 1.0 version, the API may change with minor releases.
Breaking changes will be announced in the changelog.
Since the API is fully typed, your typechecker and/or IDE
will help you adjust to any API changes.LicenseThis library is licensed under the terms of the MIT license.
It also includes short scripts from other projects (seepdfje/vendor),
which are either also MIT licensed, or in the public domain.ContributingHere are some useful tips for developing in thepdfjecodebase itself:Install dependencies withpoetry install.To write output files during tests, usepytest--output-path=<outpur-dir>To also run more comprehensive but ‘slow’ tests, usepytest--runslowAcknowledgementspdfjeis inspired by the following projects.
If you’re looking for a PDF writer, you may want to check them out as well:python-typesettingfpdf2ReportLabWeasyPrintborbwkhtmltopdfpydyf