Skip to content
 
 

Latest commit

 

History

383 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG-for-PDFKit

Insert SVG into a PDF document. This repository holds two independent packages that convert the same SVG feature set to two different PDF backends.

Package Backend Use it with
svg-for-pdfkit PDFKit SVGtoPDF(doc, svg, x, y, options)
svg4pdf-lib @pdfme/pdf-lib drawSvg(page, svg, x, y, options)

svg-for-pdfkit is a maintained fork of SVG-to-PDFKit by alafr. svg4pdf-lib does not depend on it and does not use PDFKit: it emits pdf-lib operators directly, in a single conversion pass. See each package's README for its API, supported features and limitations.

Repository layout

packages/svg-for-pdfkit/   plain-JS SVG → PDFKit converter (+ examples, notes)
packages/svg4pdf-lib/      TypeScript SVG → pdf-lib converter

The two packages are versioned and released independently; changes to one do not require a release of the other.

Development

This is a pnpm workspace.

pnpm install
pnpm build          # both packages
pnpm test           # both packages

To work on a single package:

pnpm --filter svg4pdf-lib build
pnpm --filter svg4pdf-lib test
pnpm --filter svg4pdf-lib test:watch

svg-for-pdfkit is plain JavaScript, so its build script only prints a notice; its test script runs scripts/smoke.mjs, which generates a PDF with PDFKit.

Releasing

Each package is published on its own, so a release is always done from inside that package's directory.

To release one package:

cd packages/svg4pdf-lib       # or packages/svg-for-pdfkit

# 1. set the new version in package.json
# 2. publish
pnpm publish

# 3. back in the repo root, record the release
git commit -am "svg4pdf-lib 0.2.0"
git tag svg4pdf-lib@0.2.0
git push origin main --tags

To release both, do this once per package, each with its own version.

That is all there is to it: pnpm publish builds svg4pdf-lib first (via its prepack script), and svg-for-pdfkit needs no build step.

A few things worth knowing:

  • You must be logged in to npm; run npm login if npm whoami reports E401.
  • Preview what will be uploaded with pnpm publish --dry-run. The version must be higher than what is already published, otherwise the publish is refused.
  • Tag with the package name (svg4pdf-lib@0.2.0). Unprefixed tags such as 0.1.18 predate the split into two packages and are ambiguous.

License

LGPL-3.0-or-later. The original SVG-to-PDFKit code remains available under the MIT License, reproduced in each package's LICENSE file.

About

Insert SVG into a PDF document created with PDFKit

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages