GitXplorerGitXplorer
a

pdfje

public
25 stars
0 forks
2 issues

Commits

List of commits on branch main.
Unverified
1d258e7f097be4343b6f5fabe390b3f94d63ec4f

Bump hypothesis from 6.112.0 to 6.112.1

ddependabot[bot] committed 4 days ago
Unverified
24627a07daf89ae733fb9b695a1980a5ce4d8406

Bump pytest from 8.3.2 to 8.3.3

ddependabot[bot] committed 9 days ago
Unverified
ab49317234213433dc049f61629b6064b6f82c1a

Update sphinx-autodoc-typehints requirement from ~=2.3 to ~=2.4

ddependabot[bot] committed 11 days ago
Unverified
5598ff206635a00f7c3a6787831e5425c9a68a17

Bump hypothesis from 6.111.2 to 6.112.0

ddependabot[bot] committed 14 days ago
Unverified
1194c373d8cd5dc3a938785a3cc7c17688a91bf0

Update sphinx-autodoc-typehints requirement from ~=2.2 to ~=2.3

ddependabot[bot] committed 21 days ago
Unverified
5a8416125eb62fca15f817b88a0914f7a3c27d35

Bump hypothesis from 6.111.1 to 6.111.2

ddependabot[bot] committed 25 days ago

README

The README file for this repository.

๐ŸŒท pdfje

.. image:: https://img.shields.io/pypi/v/pdfje.svg?style=flat-square&color=blue :target: https://pypi.python.org/pypi/pdfje

.. image:: https://img.shields.io/pypi/pyversions/pdfje.svg?style=flat-square :target: https://pypi.python.org/pypi/pdfje

.. image:: https://img.shields.io/pypi/l/pdfje.svg?style=flat-square&color=blue :target: https://pypi.python.org/pypi/pdfje

.. image:: https://img.shields.io/badge/mypy-strict-forestgreen?style=flat-square :target: https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-strict

.. image:: https://img.shields.io/badge/coverage-99%25-forestgreen?style=flat-square :target: https://github.com/ariebovenberg/pdfje

.. image:: https://img.shields.io/github/actions/workflow/status/ariebovenberg/pdfje/tests.yml?branch=main&style=flat-square :target: https://github.com/ariebovenberg/pdfje

.. image:: https://img.shields.io/readthedocs/pdfje.svg?style=flat-square :target: http://pdfje.readthedocs.io/

..

pdfยทje [๐Ÿ”‰ <https://upload.wikimedia.org/wikipedia/commons/a/ac/Nl-pdf%27je.ogg>_ PDFยทyuh] (noun) Dutch for 'small PDF'

Write beautiful PDFs in declarative Python.

(Currently in development. Leave a โญ๏ธ on GitHub if you're interested how this develops!)

Features

What makes pdfje stand out from the other PDF writers? Here are some of the highlights:

๐Ÿงฉ Declarative API


In most PDF writers, you create empty objects and
then mutate them with methods like ``addText()``,
all while changing the state with methods like ``setFont()``.
**Pdfje** is 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.

.. code-block:: python

  from pdfje import Document
  Document("Olรก Mundo!").write("hello.pdf")

See `the tutorial <https://pdfje.rtfd.io/en/latest/tutorial.html>`_
for a complete overview of features, including:

- Styling text including font, size, and color
- Automatic layout of text into one or more columns
- Builtin and embedded fonts
- Drawing basic shapes

See the roadmap_ for supported features.

๐Ÿ“– Decent typography

Legibility counts. Good typography is a key part of that. Pdfje supports several features to make your documents look great:

  • Visually pleasing linebreaks, using the same basic principles as LaTeX <https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Knuth's_algorithm>_
  • Automatic kerning <https://en.wikipedia.org/wiki/Kerning>_ using available font metrics
  • Avoiding widows and orphans <https://en.wikipedia.org/wiki/Widows_and_orphans>_ by moving lines between columns or pages.

.. image:: https://github.com/ariebovenberg/pdfje/raw/main/sample.png :alt: Sample document with two columns of text

๐ŸŽˆ Small footprint


The 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 is **pdfje** pure-Python, it allows you to
install only the dependencies you need.

.. code-block:: bash

  pip install pdfje                 # no dependencies
  pip install pdfje[fonts, hyphens] # embedded fonts and improved hyphenation

.. _roadmap:

Roadmap
-------

**Pdfje** has basic functionality,
but is not yet feature-complete.
Until the 1.0 version, the API may change with minor releases.

Features:

โœ… = implemented, ๐Ÿšง = may be planned, โŒ = not planned

- Typesetting
    - โœ… 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 wrapping
- Drawing operations
    - โœ… Lines
    - โœ… Rectangles
    - โœ… Circles, ellipses
    - ๐Ÿšง Arbitrary paths, fills, and strokes
- Text 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
- โŒ Annotations

Versioning and compatibility policy
-----------------------------------

**Pdfje** follows 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.

License
-------

This library is licensed under the terms of the MIT license.
It also includes short scripts from other projects (see ``pdfje/vendor``),
which are either also MIT licensed, or in the public domain.

Contributing
------------

Here are some useful tips for developing in the ``pdfje`` codebase itself:

- Install dependencies with ``poetry install``.
- To write output files during tests, use ``pytest --output-path=<outpur-dir>``
- To also run more comprehensive but 'slow' tests, use ``pytest --runslow``

Acknowledgements
----------------

**pdfje** is inspired by the following projects.
If you're looking for a PDF writer, you may want to check them out as well:

- `python-typesetting <https://github.com/brandon-rhodes/python-typesetting>`_
- `fpdf2 <https://pyfpdf.github.io/fpdf2/index.html>`_
- `ReportLab <https://www.reportlab.com/>`_
- `WeasyPrint <https://weasyprint.org/>`_
- `borb <httpsL//github.com/jorisschellekens/borb/>`_
- `wkhtmltopdf <https://wkhtmltopdf.org/>`_
- `pydyf <https://github.com/CourtBouillon/pydyf>`_