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

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.2
File Size Uploaded Provenance Actions
vec_io-0.7.2.tar.gz 2.2 MB Without provenance Details for vec_io-0.7.2.tar.gz

Built distributions (wheels)

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

Total release size: 10.4 MB

Release files / vec_io-0.7.2.tar.gz

Download URL vec_io-0.7.2.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
42f78bae03de23858c2fd7f04e30573825e2e3ec0bfccedf6af157808ae008a2
BLAKE2b-256 checksum
How to use checksums
b0b313499f7cd006005d3a2ccab9570e8a099ce5220e849f36ae916537f6b79a
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.2-py3-none-win_arm64.whl

Download URL vec_io-0.7.2-py3-none-win_arm64.whl
Size 1.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
e4e2632cfde528e0ad2bd2df1b295142d5f7e4128718b5d2eafa673e6b8d4c9c
BLAKE2b-256 checksum
How to use checksums
851068a04d817974a88579b68953e382bdd0c93a1f3a43ff304810447b0da070
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.2-py3-none-win_amd64.whl

Download URL vec_io-0.7.2-py3-none-win_amd64.whl
Size 1.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
de17ddf34545f5fbcf3f01d21b7467540a6bdb849cc5689ef46ce455525b5f01
BLAKE2b-256 checksum
How to use checksums
5fcb2cb4582e42a12cb721ff73e119e5d390bbbb8fa9d35f11c983b01cf7d617
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.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL vec_io-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Size 1.7 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
4907bf0a69d6d5a1db1e6a90016d382feabae0cca0480a0297e98f18932030fb
BLAKE2b-256 checksum
How to use checksums
7f58b267e05f620fbf68624e797e65d7542dea746d95238a7fc8d4e0c5615db1
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.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL vec_io-0.7.2-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
7cbf6ff15d9eeccb685dcf79f6d3db5d172fdc01d16d8e707bbd8ef21dc5879c
BLAKE2b-256 checksum
How to use checksums
8dd16efa677264c351cf3dfe20aa3b3550623a4ff2be0b25f6c50ed802c8e7c5
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.2-py3-none-macosx_13_0_arm64.whl

Download URL vec_io-0.7.2-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
f70d33df2c4b0a6f7dece17293d68694bffc781b69fa43803e07d5792caf0b43
BLAKE2b-256 checksum
How to use checksums
9745e17dbf6afbfb70efc95de3aee21df82e9fb50863081e37a0c19d226f8336
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.2

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