Who it is forA developer or agent operator who already has a translated HTML file laid out with CSS @page rules and needs a print-ready PDF.
The problemLonger translated text can overflow the page height and push content onto extra blank or broken pages when printed.
The outcomeA vector PDF that keeps text selectable, or a failed run that reports the overflow so the HTML can be fixed before a PDF is written.
What you need first
- Python with pip installed
- Git to clone the repository
- Playwright Chromium installed with `playwright install chromium`, or Microsoft Edge on Windows
- The original PDF to translate or audit
- An AI agent or language model that can write HTML and run Python commands, if you want the translation step done for you
Steps
- Clone the repository with
git clone https://github.com/lxsssssss/pdf-translate.gitand enter it withcd pdf-translate. - Install dependencies with
pip install -r requirements.txtandplaywright install chromium. - Place your translated HTML file in the project folder and name it input.html.
- Render it in strict mode with
python scripts/render_pdf.py input.html output.pdf --strict-overflow. - If the command exits with code 2, fix the reported overflow in the HTML and run the render command again.
Prompt for your agent
In the pdf-translate repository, render <input.html> to <output.pdf> using scripts/render_pdf.py with --strict-overflow. If the exit code is 2, edit the HTML to remove the reported page overflow and render again. Verify that output.pdf exists and has the expected page count before finishing.
Caveat. The renderer takes an HTML file as input, so the translation and layout into HTML must already exist; the README does not describe a command that produces that HTML from a PDF.
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer