Skip to main content

vec_io

Vector graphics in Python: read SVG and PDF, draw pages and plot data, write PDF, SVG, SVGZ, EPS, PNG, JPEG, JPEG XL, AVIF or TIFF. No dependencies: a bundled C library does the heavy lifting.

Install

pip install vec_io

Python 3.11+. Wheels hold the C library prebuilt for Linux (x86_64, aarch64; glibc or musl), Windows (x86_64, arm64) and macOS 13+ (arm64). Elsewhere pip builds it from the sdist with the local C compiler (gcc or clang; on Windows clang or MinGW, not MSVC). Without the library, drawing calls still record, but every output and the bulk calls raise NativeLibraryError. vec_io doctor checks the installation.

Example

import vec_io

svg_text = ('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100">'
            '<circle cx="50" cy="50" r="40" fill="#e30613"/></svg>')
vec_io.convert(svg_text, "circle.pdf")                 # SVG text, a path or bytes
vec_io.convert("drawing.svg", "drawing.png", dpi=192)  # the format from the extension

doc = vec_io.Document(unit="mm", title="Report")       # one unit for pages, calls and fonts
page = doc.add_page(width=120, height=60)              # origin top-left
page.draw_rect(10, 10, 100, 40, rx=3, fill="#1f6fb2")
page.draw_text("Hello", 20, 35, fill="white", font_size=12, font_weight="bold")
doc.save("hello.pdf")
doc.save("hello.svg")                                  # the same record, another format

A document records what is drawn; each output (write, save, render) is made from the record with its own options, and drawing may go on after a save. In a notebook, pages, documents, drawings and images show themselves as SVG.

Features

  • Convert SVG and PDF to every output format: shapes, text with embedded font subsets, gradients, patterns, clips, masks, markers, filters, images and CSS. Blank borders cut (--trim), the output resized (--width 8.5in, --size us --margin 1in), images resampled (--dpi 300).
  • Draw on pages with Document and Page (SVG's style names, a style per call or per state(), any unit): pages, links, bookmarks, metadata, placed SVG and PDF files, text along paths, filters on any group; or build drawings of elements with vec_io.draw.
  • Read PDF (and Illustrator .ai) into documents: text stays text, every font kind, encrypted and damaged files, colour spaces and overprint kept; PDFFile merges, splits, rotates and crops PDF files without interpreting them.
  • Lay out text: paragraphs in boxes, justified, hyphenated, greedy or Knuth–Plass, rich text with links, overflow into further boxes; bidi; shaping and measuring without a page (vec_io.text).
  • Plot data: markers, lines of millions of points, areas, segments, bars, polygons and grids of cells, from sequences or buffers (numpy arrays); simplify leaves out what does not show. Axes and colour maps are plot_io's.
  • Fonts: installed fonts, font files, @font-face, variable fonts; a family that is not installed is downloaded once and cached (Google Fonts, URW, CTAN, Fontsource, Fontshare).
  • Print and archive: CMYK, spot colours, ink limit, ICC output intent; PDF/A-2b, 2u and 3b with attachments; transparency flattened for EPS and PDF.
  • Untrusted input: vec_io.Limits bounds what a call may spend; past it, LimitError.
  • Small files: PNG in its smallest lossless layout or a lossy palette, progressive JPEG, JPEG XL and AVIF when their libraries are installed.

Command line

vec_io convert drawing.svg out.pdf                 # any output format
vec_io convert --trim --margin 2mm figure.svg figure.png
vec_io convert report.pdf "page-{page:02}.svg"     # one file per page
vec_io pages a.pdf b.svg -o out.pdf --select 1-3,5 --nup 2x2 --size a4
vec_io info report.pdf --json                      # pages, fonts, images, metadata
vec_io fonts find "Helvetica"                      # the file a family resolves to
vec_io text report.pdf                             # the text, in reading order

Every command takes - for stdin or stdout; vec_io COMMAND --help lists its flags.

Documentation

  • Tutorial: first steps.
  • Examples: nine scripts with their images, and recipes.
  • API: the guide by topic: conventions, drawing, text, output options, SVG support, fonts, limits, the command line.
  • Reference: a page per class.

Limits

  • Complex scripts (Arabic, Indic, Thai…) are joined only when HarfBuzz is installed; without it they are drawn unjoined, with a warning.
  • Text needs an outline font; with none installed, supplied or downloaded, NoFontError.
  • Filters are pixels in PDF and EPS, <filter> elements in SVG.
  • URLs an SVG refers to are fetched unless network=False (use it for untrusted input).
  • Overprint is kept in PDF output, not simulated in images. Animation and scripts are ignored.

Development

python tools/check.py                      # every check, in one gate (--fast, --list)
python -m unittest discover -s tests -t tests
python tools/gen_docs.py                   # the generated parts of docs/ (--check, --images)
python tools/regress.py --render --check   # output against HEAD on tests/corpus
pip install --require-hashes -r tools/zig.lock
python tools/build_native.py               # vec_io/native/bin/* (not in git)

check.py runs the suite, ruff, mypy, the docs (generated parts, code blocks, links, images), the examples (their SVGs equal the committed ones where Helvetica is installed), the binaries rebuilt byte for byte, the fuzz suite, the corpus through poppler and Chrome. Tests use their own font (tests/fonts) and never download. The C library and its rules are described in vec_io/native/README.md.

Metadata

Release files for vec-io 0.7.0

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

Source distribution (sdist)

Source distribution for vec-io 0.7.0
File Size Uploaded Provenance Actions
vec_io-0.7.0.tar.gz 2.2 MB Without provenance Details for vec_io-0.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for vec-io 0.7.0
File Actions
vec_io-0.7.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for vec_io-0.7.0-py3-none-win_arm64.whl
vec_io-0.7.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for vec_io-0.7.0-py3-none-win_amd64.whl
vec_io-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64, Linux glibc 2.17+ x86-64 Details for vec_io-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
vec_io-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux musl 1.1+ ARM64 Details for vec_io-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
vec_io-0.7.0-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for vec_io-0.7.0-py3-none-macosx_13_0_arm64.whl

Total release size: 10.3 MB

Release files / vec_io-0.7.0.tar.gz

Download URL vec_io-0.7.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
c2a89ea8c05c5beeb91aff751aa37a082348924bc6227b429c877db5e18e43a3
BLAKE2b-256 checksum
How to use checksums
96460e84d37bb5a6e0351f97f803618528b9f086ba9b0b77f641acbceb1c202f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / vec_io-0.7.0-py3-none-win_arm64.whl

Download URL vec_io-0.7.0-py3-none-win_arm64.whl
Size 1.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
640f5c91cc5d924f74f5fcc49508f4dabfc26a05be91221db13ccf423fb796bb
BLAKE2b-256 checksum
How to use checksums
f198b8a613b4dbe24f17eb55877d6e3e6c0b383aa852db3ace5201dfafc39b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / vec_io-0.7.0-py3-none-win_amd64.whl

Download URL vec_io-0.7.0-py3-none-win_amd64.whl
Size 1.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
231d59b123cc092f277cff3e20ed7e917eb7d019852cc328de3b5d211bd75ea7
BLAKE2b-256 checksum
How to use checksums
7f3afb2d7a6b45f2bd83b8891ed77c6f7fe63deadd561ead722e0284e04f2367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / vec_io-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL vec_io-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Size 1.6 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
92b38feb30f45f6726711faa3458e852cec892e3cdfd607c6bac07fdde4b65ec
BLAKE2b-256 checksum
How to use checksums
f1d5ae4fd9f51fb64d5cea4fbba94cd4f9abefd582086179c1d51339eada0ccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / vec_io-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL vec_io-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Size 1.6 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
228675e526bc98d42af1201d4e7007d9ffb4c779e1c2d5b2dd89d5141b904e0a
BLAKE2b-256 checksum
How to use checksums
f12d86a6093b5111a9438fd57e065d6abc64b313899d1fd184662cfec688a303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / vec_io-0.7.0-py3-none-macosx_13_0_arm64.whl

Download URL vec_io-0.7.0-py3-none-macosx_13_0_arm64.whl
Size 1.6 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
024d18410ed75da84c6b5f55b2f0a70dacd4127c59a9a46219aba8d9e002e028
BLAKE2b-256 checksum
How to use checksums
e35a90cfc6902d97b6d3a18e152665f5c7ad52dc5731b0550d446379e2bf093a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for vec-io 0.7.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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