# PDFs

> How VisualCI renders, fingerprints and compares PDFs, page by page, in one pinned environment.

Source: https://visualci.com/docs/pdfs/
All of VisualCI's documentation: https://visualci.com/llms.txt

Send the PDFs your tests generate:

```sh
visualci upload spec/artifacts/pdfs
```

## One renderer for every run

A Mac and a Linux CI machine rasterize the same PDF differently. So VisualCI renders PDFs itself, with one pinned renderer and its fonts, in a Linux image on its servers. A run on a laptop and a run in CI get the same pixels and the same baseline.

Each project picks:

- the renderer: `pdfbox` (the default) or `mutool`;
- the resolution: 36 to 600 dpi.

Both are on the project's **Settings** tab, or `update_project` over MCP. `--engine pdfbox|mutool` overrides the renderer for some uploads. The renderers run sandboxed, with no network access.

Documents are compared exactly by default: any changed pixel is a change.

## Fingerprints

Before uploading, the CLI fingerprints each PDF by what it draws. The fingerprint leaves out creation dates, document IDs and producer strings, so a regenerated PDF that draws the same thing still matches, and nothing is uploaded, rendered or diffed.

Each page is fingerprinted too, so pages are matched by content instead of by position. A document that gains a page shows one inserted page, not every later page changed.

`visualci compare-runs <dir1> <dir2>` checks that your PDFs' fingerprints are stable: run your tests twice, then compare the two output directories. It exits 1 when a fingerprint differs, which usually means the PDF draws something that changes on every run, such as the current time.

## What a change looks like

For each changed page, `get_snapshot` (and the web app) shows:

- the base, head and diff images, with changed regions boxed;
- the page's text diff: the renderer extracts each page's text;
- lines that moved to another page, the usual sign of a page-break bug;
- inserted and removed pages, next to an empty slot on the other side.
