Create PDF files with Typst and LibreOffice, and inspect them with Poppler tools.
732
Create PDF files with Typst and LibreOffice, and inspect them with Poppler tools.
Use this image for document builds, report conversion, and PDF checks. It contains:
pdfinfo, pdftotext, and pdftoppm.The working directory is /workspace. The default command starts Bash. The
LibreOffice package runs only on linux/amd64.
| Tag | Meaning | Platform |
|---|---|---|
latest | Latest successful build from main. | linux/amd64 |
View all tags on Docker Hub.
The latest tag changes when a new build passes its tests.
docker pull stden/document-tools:latest
Run these commands in the directory where you want to save the document:
printf '= Hello from Docker\nThis PDF was built with Typst.\n' > report.typ
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
typst compile report.typ report.pdf
The mount saves report.pdf on your host. If your document uses Typst packages,
network access can be necessary at their first use.
Put report.docx in the current directory. Then run this command:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
libreoffice -env:UserInstallation=file:///tmp/lo-profile --headless \
--convert-to pdf --outdir /workspace report.docx
The same command can convert supported office files, such as .odt, .xlsx,
and .pptx. Change the input file name. LibreOffice can also convert a text file
to DOCX:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
libreoffice -env:UserInstallation=file:///tmp/lo-profile --headless \
--convert-to docx --outdir /workspace notes.txt
Each command uses a temporary LibreOffice profile inside its container. Supply the fonts that your source document uses. Missing fonts can change the layout.
Show the page count, the page size, and the document metadata:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
pdfinfo report.pdf
Extract the text and keep the page layout:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
pdftotext -layout report.pdf report.txt
Create a PNG image of the first page for a visual check:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
pdftoppm -f 1 -singlefile -png -r 150 report.pdf report-page
The last command saves report-page.png. Text extraction works on PDF text. It
does not do OCR on scanned pages.
Mount the project directory and run your Python script:
docker run --rm -v "$PWD":/workspace stden/document-tools:latest \
python check_report.py
Install extra Python libraries in a child image that starts with
FROM stden/document-tools:latest. All generated files in /workspace stay
on the host. The default container user is root, so on Linux the output files can
belong to root.
The smoke test creates a Typst PDF, converts text to DOCX and PDF with LibreOffice, and checks the extracted text.
Content type
Image
Digest
sha256:bd32d4730…
Size
749.8 MB
Last updated
1 day ago
docker pull stden/document-tools