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

Built distributions (wheels)

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

Total release size: 10.3 MB

Release files / vec_io-0.7.1.tar.gz

Download URL vec_io-0.7.1.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
23a1531821d9c0e7a65f909d1910a87e84308c6692f819f0375f87c0d2130287
BLAKE2b-256 checksum
How to use checksums
f4d3b0488be5b0f80ef2f61c9da8c964f442f49cfd86bb66b4b262c694feb2c0
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.1-py3-none-win_arm64.whl

Download URL vec_io-0.7.1-py3-none-win_arm64.whl
Size 1.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
5e3a1d029e9c39be241fd00d895fea9d083168f75da56852655cb845b4729384
BLAKE2b-256 checksum
How to use checksums
2397e4e91ebd1848755be1f05c0f4ed7c2a575416cb11f6f7b62e01cc4b53695
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.1-py3-none-win_amd64.whl

Download URL vec_io-0.7.1-py3-none-win_amd64.whl
Size 1.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
9a5a0755e969d5fe5360d34ccbfe9698cd31e081e0fbfc48b69722b13b8e5a18
BLAKE2b-256 checksum
How to use checksums
7ae7955aa0d34a2666ffe620f02f1ddc3b95117482ccf624e30d06bca40fd7d5
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.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL vec_io-0.7.1-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
97cf369c9bd9e9708b9100a59b7319684bfef7a5ebb601590367678e9710decf
BLAKE2b-256 checksum
How to use checksums
7bc94d30527f801aecefae78d1e2e7c7756cb77f7e73e83b4fbeff85c2306692
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.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL vec_io-0.7.1-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
d6ee71df5ba0aa74498d3e60bbf595d5ea41bd63f2b478dfb8ced4e6c2b2ab30
BLAKE2b-256 checksum
How to use checksums
9a4cbe79199149eedbf1f72ba0bf6302da22839b0a1d87d381a6ed6a855ffe65
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.1-py3-none-macosx_13_0_arm64.whl

Download URL vec_io-0.7.1-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
419af4d6aadb68d38fe98437ddee65e72e409a71a75ec04e5dc539c51693df27
BLAKE2b-256 checksum
How to use checksums
0d7df508ee17ddd3a13b7177fcd41d6c4062a0b07d52c3d6fb157d7e69447fb4
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.1

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