document-svg for Python
Turn PDF, Word, Excel, PowerPoint, diagram and CAD files into SVG pages from Python — locally, without Office.
Project site · Formats · Samples · 日本語 · 简体中文
document-svg turns a document, diagram or drawing into ordinary SVG images,
one per page, that any browser can show. It also tells you, page by page, what
it could not reproduce exactly, so you can decide whether the result is good
enough to use.
- Files stay on your machine. Nothing is uploaded and there is no account.
- Nothing inside a file is run. Macros, scripts and external links are shown or skipped, never executed.
- No Office, no viewer, no headless browser. One package handles Office files, PDFs, diagrams, CAD and 3D models, and many data formats.
The same converter is also available for Node.js on npm
and for Rust, with the docsvg command, on crates.io.
Install
Requires Python 3.10 or newer.
python -m pip install document-svg
Install document-svg, import document_svg. Ready-made packages cover
Windows, macOS and Linux (Ubuntu, Debian and other glibc systems) on x64 and
ARM64, so you don't need Rust. On Alpine and other musl systems, pip builds
from source, which needs Rust and a C linker. This package gives you a Python
API; for the docsvg command, see crates.io.
The package goes into your environment's site-packages/document_svg.
python -m pip show document-svg shows the installed version and location.
Save SVG pages to a folder
from document_svg import convert
report = convert("report.pdf", "out/report")
print(report["page_count"], report["warnings"])
The output folder must be new or empty. It receives page-0001.svg,
page-0002.svg, … and a conversion.json report. Conversion runs without
holding Python's GIL, so other threads keep working.
Useful options:
max_pages— stop after this many pages.jobs— convert several pages at once.outline_embedded_pdf_text=True— for PDFs, draw text as shapes so it looks exactly like the original on any computer (the text can no longer be selected).embed_drawio_source=True— for draw.io files, keep the diagram inside each SVG so it can later be turned back into an editable diagram.
Get SVG pages in memory
preview() returns every page as SVG text without writing files — handy for
a web API or a notebook.
from document_svg import preview
result = preview("slides.pptx", max_pages=20)
first_page_svg = result["pages"][0]["svg"]
if result["needs_review"]:
print("Some parts were approximated:", result["warnings"])
When you show pages in a web page, show them as images (for example an
<img> element) rather than inserting the SVG markup into your HTML.
Read the result before you share it
Every result has warnings: things that were approximated or left out, such
as a substituted font or an unsupported fill. Finishing without an error is not
the same as perfect. When there are warnings, have a person look at the pages.
Text uses the fonts available where the SVG is shown, so it can look slightly different on another computer.
Turn SVG pages back into files
from document_svg import reverse
reverse("out/slides", "slides.pptx") # a folder of pages
reverse("drawing.svg", "drawing.dxf") # or a single SVG
The extension decides the format: PowerPoint, Word, Excel, draw.io, DXF,
G-code, Gerber, HP-GL and more. What comes back is how the pages look;
paragraphs, cells and formulas are not rebuilt. A draw.io diagram converted
with embed_drawio_source=True comes back editable.
Tidy up an SVG
from document_svg import transform
smaller = transform(svg, minify=True, remove_metadata=True)
transform() can also recolour to one colour, make the SVG scale to its
container, and clean up paths and empty groups. It returns str for str
input and bytes for bytes input.
Which files work?
PDF, Word, Excel and PowerPoint (current and older formats), OpenDocument, e-mail, e-books, draw.io, Visio, Mermaid, PlantUML, DXF, Gerber, G-code, STL, STEP, IFC, simulation meshes, CSV, JSON, maps, images, DICOM and more. Some formats are drawn in full; others show a summary of their contents. Look up your file type in the searchable format list.
Safety
- Treat uploaded files as untrusted. On a public service, run conversion in a separate process with memory and time limits.
- Input size, archive contents and page count are limited by default. Don't raise the limits just to push a difficult file through.
- A PDF that needs a password to open is refused.
- Medical images and reports are not anonymized: personal information in the file can appear in the output.
More in Safety and limits and the security policy.
Reference
Every function, option, default and exception is listed in the developer reference.
Building from source
For contributors, from bindings/python (Rust required):
python -m pip wheel --no-deps --wheel-dir dist .
License
MIT OR Apache-2.0. See the repository for the license texts and third-party notices.
Release files for document-svg 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| document_svg-2.0.2.tar.gz | 2.9 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| document_svg-2.0.2-cp310-abi3-win_arm64.whl | CPython 3.10 | abi3 | Windows ARM64 | Details |
| document_svg-2.0.2-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| document_svg-2.0.2-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| document_svg-2.0.2-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| document_svg-2.0.2-cp310-abi3-macosx_11_0_x86_64.whl | CPython 3.10 | abi3 | macOS 11.0+ x86-64 | Details |
| document_svg-2.0.2-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 69.6 MB
Release files / document_svg-2.0.2.tar.gz
| Download URL | document_svg-2.0.2.tar.gz |
|---|---|
| Size | 2.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
810b6ee75e1ef55ce8896a57735c5060666c63dc66a05a3ee3509099785b6f02
|
|
BLAKE2b-256 checksum How to use checksums |
1bd1c19d5359c2f0ea56c44e29bd5a44a57e961309c40864ac604a297b79743a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-win_arm64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 10.8 MB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0d195f892500b326b7c62018178d9d8319bac7a72c47760e31374226a73514bf
|
|
BLAKE2b-256 checksum How to use checksums |
3594ccf3ecff30c19a997401f35e0c89790021d9392fdc8429c71a1914d76cf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-win_amd64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 11.8 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
28eb4116c0e3391c4887c938e40dcb063d02adca587cc9b05a5113b302cd2b44
|
|
BLAKE2b-256 checksum How to use checksums |
3c804f5357e6afa5cb7a625a5dbad170fdae5c18605a51b46e0206b033899f91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.5 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c95565ecc79fb44f9b5a5dd2ec8d81e5879baf86fe75bf435ce7eab699e00395
|
|
BLAKE2b-256 checksum How to use checksums |
36c1fa01e61e6487abcb2141d73576a2a989530e83dc696159c0e8d89326e676
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 10.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
764f132ad5a7798deb00cbce1464faf1990cfb91bf51c76326336d05ead8e42a
|
|
BLAKE2b-256 checksum How to use checksums |
a66b49a09470e55f6cf5cdf136d3dc86d2c75e823e610a609e9bc2c70c19da37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-macosx_11_0_x86_64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 11.1 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
549bac404c60456a34fecf7ea04737b809ac7889b1a28768e70563bc94f69e66
|
|
BLAKE2b-256 checksum How to use checksums |
fc53662ef3e6bb167f5702c0e6da5e2cea7a01e545cf2a2538df3f20c8cbcbde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / document_svg-2.0.2-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | document_svg-2.0.2-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 10.4 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
54287b811fc4b0bef85824b78b7a7da0263d071042036bd9e2495df76c07c233
|
|
BLAKE2b-256 checksum How to use checksums |
233033e2f758e8a38bdb5ad2707d0c44b519b9bc44c2d3dafa4226d137b6f27a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency log