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

Built distributions (wheels)

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

Total release size: 10.5 MB

Release files / vec_io-0.8.0.tar.gz

Download URL vec_io-0.8.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
3e11c3d74436601ff5087843664324da43a26fdf09c2b762e866497558adc97c
BLAKE2b-256 checksum
How to use checksums
409d9ab167637847fe8903d73e316a51fa2af2bf8c2040a10555aba6d13ffc16
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.8.0-py3-none-win_arm64.whl

Download URL vec_io-0.8.0-py3-none-win_arm64.whl
Size 1.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
5bcb1b255dc38bb9d5330f6c9752174888268bbc0f82bc99ee0cfc396890c25d
BLAKE2b-256 checksum
How to use checksums
fa52bf959f50a8b87049e719df25668c01ce948b2a76e9e4334589446b097cf6
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.8.0-py3-none-win_amd64.whl

Download URL vec_io-0.8.0-py3-none-win_amd64.whl
Size 1.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
12e0208aa7b15674c422fe21ac0e6c2f96ba41b01b0cb37a7d4366a0649b550b
BLAKE2b-256 checksum
How to use checksums
8409206e52cad823ddca26d336b8292a58881bbf3f7dad4be3572bd606a9a8c1
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.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL vec_io-0.8.0-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
89672b0730492ade90ccf09bc4e61476d16fa2bef9a4f65d062d8fa2a89a9a5d
BLAKE2b-256 checksum
How to use checksums
2e86d259ebfc67e4a210d6ac44b62e908b7b87cf2c6fe7242a95c44f3612887a
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.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL vec_io-0.8.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
207c781dc5c35652d3421eef81dfef0cfd5ef04eae94120338703503a4d67ad8
BLAKE2b-256 checksum
How to use checksums
cc4c978fbf3b84d1078693ae2abc4236bd4f6264a69295b2fb79f2c10e60c0ff
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.8.0-py3-none-macosx_13_0_arm64.whl

Download URL vec_io-0.8.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
cc51186aaad3329864a99ca0e0971e9a04758dbcbf5e7d10959f62a3ac60a107
BLAKE2b-256 checksum
How to use checksums
1ea8471d2fafb5cd7c79db5f24039f7c69d655c93d01bda953038bc9586cc720
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.8.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