Skip to main content

The command-line Inkscape eXporter, Makefile and LaTeX friendly

Project description

ScapeX — The command-line Inkscape eXporter, Makefile and LaTeX friendly


ScapeX is a Python utility that invokes Inkscape to export an SVG drawing into a single PDF file or a set of PDFs.

It is designed to export high-quality drawings, graphics, and diagrams, hence the choice of the PDF format for vector graphics. The design of the command-line interface makes it suitable for on-the-fly usage or integration in a Makefile-based build system (e.g., for LaTeX). In addition, thanks to its fragments export feature, this tool can be used to create animated slides (e.g., using Beamer).

Features

  • Command-line interface with autocompletion
  • Each figure export can be configured via a sidecar TOML file
  • The fragments export mode creates multiple PDFs based on arbitrary layer combinations
  • Fonts rendering can be performed either by Inkscape during export or by LaTeX during compilation
  • Out-of-tree export capability

Installation

The easiest way to install ScapeX is to use PipX, a Pip wrapper that automatically creates a virtual environment.

pipx install scapex

To enable Zsh autocompletion, add the following to your ~/.zshrc:

[!WARNING] This must be added before the very first call to compinit (which initializes the autocompletion system).

which scapex >/dev/null && fpath+=($(scapex --completions-zsh))

You are ready to go!

Usage

The simplest usage is to export a single PDF file, optionally into another build directory:

scapex -o BUILD_DIRECTORY INPUT.svg

Fragments (animations)

To create animated exports, first generate a TOML configuration file for your diagram:

scapex --generate INPUT.svg

Open the file and adjust its configuration according to the layer identifiers defined in Inkscape:

vim INPUT.toml

Once ready, perform the fragments export:

scapex --fragments INPUT.svg

Interfacing with LaTeX (fonts rendering)

Fonts rendering can be delegated to LaTeX using the --fonts-engine=latex option. This will create a .pdf_tex sidecar file to the .pdf, containing the text that will be processed by LaTeX when including the exported PDF with \input{FILE.pdf_tex}:

scapex --fonts-engine=latex INPUT.svg

Interfacing with Makefile

ScapeX can also be used inside a Makefile, enabling automatic export when a drawing is modified and proper dependency handling. See the self-documented example under examples/Makefile.

Getting help

For additional usage, see scapex -h:

usage: scapex [-h] [-v] [-o OUTPUT_DIR] [--generate]
              [--fonts-engine {latex,inkscape}] [--fragments | --no-fragments]
              [--completions-zsh]
              [SVG_FILE]

The command-line Inkscape eXporter, Makefile and LaTeX friendly

positional arguments:
  SVG_FILE              Inkscape drawing in SVG format to export

options:
  -h, --help            show this help message and exit
  -v, --verbose         Increase verbosity if set
  -o, --output-dir OUTPUT_DIR
                        Set the output directory [default = .]
  --generate            Generate a TOML template configuration file for input
                        SVG file (instead of exporting)
  --fonts-engine {latex,inkscape}
                        Set the font rendering engine [default = inkscape]
  --fragments, --no-fragments
                        Enable (or disable) fragments exportation (instead of
                        full exportation) [default = False]
  --completions-zsh     Print the path of the directory containing the Zsh
                        autocompletion script (instead of exporting)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scapex-1.0.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scapex-1.0.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file scapex-1.0.0.tar.gz.

File metadata

  • Download URL: scapex-1.0.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scapex-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6e2a12c7735a8bf8e4a8fb6e489617e9dc1d856f8236f1b7cecbcac61afa926e
MD5 b9c543ff3fbd45de183add94fe961ec5
BLAKE2b-256 e76f14cb8ffd3ad91038b5188717d29a97bc7016f19a10aecdd7755272090091

See more details on using hashes here.

File details

Details for the file scapex-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: scapex-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scapex-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 acb38e2b2e048bde9cede81d50f453d6cc523fbf72980decb9286698a0ae25b5
MD5 3340e0e5694e47f07d1820ac2ea6f192
BLAKE2b-256 eda54c9588ea0fe66f6e51515d908a70a20035dc35f5e51c50b239a0818ae2f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page