Skip to main content

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.

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for document-svg 2.0.1
File Size Uploaded
document_svg-2.0.1.tar.gz 2.9 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for document-svg 2.0.1
File
document_svg-2.0.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
document_svg-2.0.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
document_svg-2.0.1-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
document_svg-2.0.1-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
document_svg-2.0.1-cp310-abi3-macosx_11_0_x86_64.whl CPython 3.10 abi3 macOS 11.0+ x86-64 Details
document_svg-2.0.1-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.1.tar.gz

Download URL document_svg-2.0.1.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
de0370d70de7d9b049837a69200ea201a760087efe108509b130892317a76643
BLAKE2b-256 checksum
How to use checksums
3ddbba192e75f8a770cfec0670b3f0df0d8d40d1b718cf9d8fe296589d579c5a
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

Release files / document_svg-2.0.1-cp310-abi3-win_arm64.whl

Download URL document_svg-2.0.1-cp310-abi3-win_arm64.whl
Size 10.8 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
4abd4c835b85b9a09e8a22cf49be663998799887a60149ec9d43397b0dfd1d3b
BLAKE2b-256 checksum
How to use checksums
56a7563f12eedacb905bb13e242eb3006cca1e6c2001b4a6497d738d082db7e8
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

Release files / document_svg-2.0.1-cp310-abi3-win_amd64.whl

Download URL document_svg-2.0.1-cp310-abi3-win_amd64.whl
Size 11.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f24b2fe858516c81a24499543290ad4ddb06471e0211e06eb244800483e7f65c
BLAKE2b-256 checksum
How to use checksums
d4f585b7468899a879c120d758901a42e57d1f2596106a9c34198af36f1685f0
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

Release files / document_svg-2.0.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL document_svg-2.0.1-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
0e509bd86274892e2c31ff7388bad103ccdaf30b2a6e39fda0c89b4e01c0ef1c
BLAKE2b-256 checksum
How to use checksums
8a83cd5f2fab54db092313cdcf221f0ac2fb43a8f76ba7feaa21a98810c56544
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

Release files / document_svg-2.0.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL document_svg-2.0.1-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
1d80d715f79c7ebcec9c6de0d0ac3cffda643f906bda1fa77564bea19c8d0eb5
BLAKE2b-256 checksum
How to use checksums
0513b15383e588abe0962e61fe7b11770abe41442f8fc51c7e5987877cc7bc46
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

Release files / document_svg-2.0.1-cp310-abi3-macosx_11_0_x86_64.whl

Download URL document_svg-2.0.1-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
229ae9f2a3adc5b246731409bb45fd8fe5701fb8e0e6a7c68dfe16002940d57c
BLAKE2b-256 checksum
How to use checksums
fb141727e4de20b9d0c7ae7c42d024451cbad195b8626e4c037999d41c9a80a9
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

Release files / document_svg-2.0.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL document_svg-2.0.1-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
b146e23d5a8f3a88419f578b3f92340eaf9c85a53d1f2f34bad39e136bc683c8
BLAKE2b-256 checksum
How to use checksums
3787b036f8bee6f7827d229e031555d52daf110d5f371430b615781850088fa6
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

Release history Release notifications | RSS feed

2.0.2

7 release files

This release

2.0.1 This release

7 release files

2.0.0

7 release files

0.1.1

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page