Converts Adobe LiveCycle XFA PDFs (which require Acrobat to open) to standard image-based PDFs readable in Preview. Uses a V8-enabled build of pypdfium2 to render XFA content, assembled into a PDF via img2pdf. Ships as a macOS Finder Quick Action; run setup.sh to install. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| Convert PDF for Preview.workflow/Contents | ||
| .gitignore | ||
| .python-version | ||
| convert_pdf.py | ||
| convert_pdf.sh | ||
| pyproject.toml | ||
| README.md | ||
| setup.sh | ||
| uv.lock | ||
PDF Tool
Converts Adobe Acrobat / XFA PDFs to standard PDFs that open in macOS Preview. Installs as a Finder Quick Action (right-click menu).
Why this exists
Some PDFs created with Adobe LiveCycle Designer use XFA (eXtensible Forms Architecture), which stores all visual content in Adobe-proprietary XML streams. Standard viewers (Preview, browsers) show only a fallback message. This tool renders the XFA content using a V8-enabled build of PDFium and re-exports it as a standard image-based PDF.
Limitation: text wrapping and font rendering may differ slightly from Adobe Acrobat due to font substitution in the open-source XFA renderer.
Prerequisites
Setup
git clone <repo> pdf_tool
cd pdf_tool
bash setup.sh
setup.sh will:
- Build and install Python dependencies (including a V8-enabled pypdfium2)
- Install the Convert PDF for Preview Quick Action to
~/Library/Services/
If the Quick Action doesn't appear immediately in Finder, log out and back in.
Usage
Quick Action: right-click one or more PDFs in Finder → Quick Actions → Convert PDF for Preview. A _converted.pdf file appears alongside each original.
Command line:
bash convert_pdf.sh file1.pdf file2.pdf
How it works
pypdfium2(built with V8/XFA support) renders each PDF page at 288 DPIimg2pdfassembles the rendered pages into a standard PDF- The output is a flat image-based PDF with no XFA or Adobe-specific dependencies
The key requirement is that pypdfium2 is built from source with PDFIUM_PLATFORM=auto-v8, which downloads a pdfium binary compiled with V8 (the JavaScript engine XFA depends on). The standard PyPI wheel omits V8 to reduce size.
Project structure
pdf_tool/
├── convert_pdf.py # core conversion logic
├── convert_pdf.sh # shell wrapper (used by Quick Action)
├── setup.sh # one-time setup for a new Mac
├── pyproject.toml # uv project + dependency config
├── uv.lock # pinned dependency versions
└── Convert PDF for Preview.workflow/ # Automator Quick Action bundle