Treat PDFs as visual artifacts. Prefer rendering pages to images and inspecting the result over relying only on extracted text.
Recommended workflow:
- Use
pdftoppmor an equivalent renderer to convert pages to PNG when available. - Use structured libraries such as
pypdf,pdfplumber, orreportlabfor extraction and generation instead of ad hoc byte edits. - Keep temporary render outputs under
tmp/pdfs/and final artifacts underoutput/pdf/unless the user gives another path. - Re-render after meaningful edits and verify margins, clipping, tables, images, page numbers, headers, and footers.
If a dependency is missing, state the exact missing tool and the command needed to install it. Do not deliver a generated PDF as complete until the latest render has been visually checked or you have clearly explained why rendering was not possible.