Our project welcomes external contributions. If you have an itch, please feel free to scratch it.
To contribute code or documentation, please submit a pull request.
A good way to familiarize yourself with the codebase and contribution process is to look for and tackle low-hanging fruit in the issue tracker. Before embarking on a more ambitious contribution, please quickly get in touch with us.
For general questions or support requests, please refer to the discussion section.
Note: We appreciate your effort, and want to avoid a situation where a contribution requires extensive rework (by you or by us), sits in backlog for a long time, or cannot be accepted at all!
If you would like to implement a new feature, please raise an issue before sending a pull request so the feature can be discussed. This is to avoid you wasting your valuable time working on a feature that the project developers are not interested in accepting into the code base.
If you would like to fix a bug, please raise an issue before sending a pull request so it can be tracked.
The project maintainers use LGTM (Looks Good To Me) in comments on the code review to indicate acceptance. A change requires LGTMs from two of the maintainers of each component affected.
For a list of the maintainers, see the MAINTAINERS.md page.
These rules keep pull requests reviewable. A pull request that does not follow them can be put on hold until it is resubmitted.
- One topic per pull request. Changes that touch the same functions or files belong to the same topic. One commit per logical fix within a pull request is fine.
- Rebase on current
mainbefore you submit, and use no merge commits. To update a branch, rungit rebase upstream/mainand push withgit push --force-with-lease. - Do not stack pull requests. Open the next pull request in a topic only after the previous one in that topic has been merged or closed.
- When a pull request replaces earlier ones, close them and link them from the description.
Every change must be shown on a real document. Synthetic test PDFs built with
tests/pdf_builder.py are welcome as unit tests, but they do not show that a
change matters in practice.
- Use the regression dataset first. If a document in it already shows the problem, name the document and the page numbers in the description, and do not open a dataset pull request.
- Open a pull request against the regression dataset only when no existing document reproduces the problem. It adds the new document, with a license that allows redistribution, and says which problem the document reproduces.
- Text, font and segmentation fixes: for each cited page, show a before/after diff of the affected text cells or words.
A rendering change must show that the output improves, which in practice means that it moves closer to pypdfium2.
- For each cited page, include a three-panel comparison: pypdfium2, before,
after.
tests/test_regression_pypdfium_render.pywrites these panels (see tests/README.md). - Include a before/after table of
mean_abs_errorandchanged_pixels_ratioagainst pypdfium2 over the whole regression corpus. The cited pages must improve, and no page may get worse by more thanPYPDFIUM_IMAGE_TOLERANCEintests/test_regression_pypdfium_render.py. - Add an image regression test that fails on
mainand passes with the change, and that compares against pypdfium2 on the cited pages.test_regression_pypdfium_render.pyonly reports differences and never fails, so on its own it does not count as this test. - Blend2D patches also need a link to the issue or pull request filed upstream with Blend2D, and a real document that crashes, hangs or renders incorrectly without the patch.
- Do not pin
HF_DATASET_REVISIONintests/constants.pyto a revision from an open dataset pull request. - If a change alters the ground truth of existing regression pages, list those pages in the description and say why each one changes. The maintainers update the ground truth when they merge.
Each source file must include a license header for the MIT Software. Using the SPDX format is the simplest approach. e.g.
/*
Copyright IBM Inc. All rights reserved.
SPDX-License-Identifier: MIT
*/
We have tried to make it as easy as possible to make contributions. This applies to how we handle the legal aspects of contribution. We use the same approach - the Developer's Certificate of Origin 1.1 (DCO) - that the Linux® Kernel community uses to manage code contributions.
We simply ask that when submitting a patch for review, the developer must include a sign-off statement in the commit message.
Here is an example Signed-off-by line, which indicates that the submitter accepts the DCO:
Signed-off-by: John Doe <john.doe@example.com>
You can include this automatically when you commit a change to your local git repository using the following command:
git commit -s
Please feel free to connect with us using the discussion section.
We use uv to manage dependencies.
To install, see the documentation here: https://docs.astral.sh/uv/getting-started/installation/
- Install uv standalone in your machine
# On macOS and Linux. curl -LsSf https://astral.sh/uv/install.sh | sh
To activate the Virtual Environment, run:
uv shellTo spawn a shell with the Virtual Environment activated. If the Virtual Environment doesn't exist, uv will create one for you. Then, to install dependencies, run:
uv install(Advanced) Use a Specific Python Version
If for whatever reason you need to work in a specific (older) version of Python, run:
uv venv use $(which python3.9)This creates a Virtual Environment with Python 3.9. For other versions, replace $(which python3.9) by the path to the interpreter (e.g., /usr/bin/python3.9) or use $(which pythonX.Y).
uv add NAMEWe use the following tools to enforce code style:
- iSort, to sort imports
- Black, to format code
We run a series of checks on the code base on every commit, using pre-commit. To install the hooks, run:
pre-commit installTo run the checks on-demand, run:
pre-commit run --all-files
Note: Checks like Black and isort will "fail" if they modify files. This is because pre-commit doesn't like to see files modified by their Hooks. In these cases, git add the modified files and git commit again.