npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

zworks

v1.8.0

Published

A javascript-only SVG to PDF conversion utility that runs in the browser leveraging jsPDF

Readme

zworks

NPM version

A javascript-only SVG to PDF conversion utility that runs in the browser leveraging jsPDF.

Installation

You can get zworks via npm:

$ npm install zworks --save

Then import via requirejs:

require.config({
  baseUrl: './node_modules' // or './bower_components'
});
require([
  'zworks/dist/svg2pdf.min',
  'jspdf-yworks/dist/jspdf.min'
], function (svg2pdf, jsPDF) {...});

or script-tag:

<script src="[node_modules|bower_components]/jspdf-yworks/dist/jspdf.min.js"></script>
<script src="[node_modules|bower_components]/zworks/dist/svg2pdf.min.js"></script>

If you want to use a development version from the repository, pay attention to the fact that the files in dist may reflect the last release version. So a simple package.json dependency link to the branch or revision will fail. See #102 for details.

Usage

const svgElement = document.getElementById('svg');
const width = 300, height = 200;

// create a new jsPDF instance
const pdf = new jsPDF('l', 'pt', [width, height]);

// render the svg element
svg2pdf(svgElement, pdf, {
	xOffset: 0,
	yOffset: 0,
	scale: 1
});

// get the data URI
const uri = pdf.output('datauristring');

// or simply save the created pdf
pdf.save('myPDF.pdf');

Concerning custom fonts

If you want to use other than really basic fonts you will have to add them first before calling svg2pdf:

pdf.addFont('myFont.ttf', 'myFont', 'normal');

Please refer to the jsPDF readme.

Reporting issues

Svg2pdf is by no means perfect. If you find something is not working as expected we are glad to receive an issue report from you. In order to be able to react efficiently we ask you to provide us with the following information:

  • The versions of svg2pdf and jsPDF you are using
  • A (preferably small) sample SVG that reproduces the issue
  • Other code snippets if necessary

If you are getting an exception "pt.saveGraphicsState is not a function" you are using the wrong fork of jsPDF! Use the yWorks fork!

Building

If you want to play with the sources or build the minified js file yourself, check out the repository and use the npm scripts defined in package.json:

npm run build

Testing

The tests folder contains a set of unit tests. Each unit test has its own folder and contains exactly two files:

  • A spec.svg file that contains the svg to test
  • A reference.pdf file that is generated automatically and serves as reference for regression testing

You can run the tests using

$ npm run createreferences && npm run test

The tests use the Karma framework and thus run in a captured browser. Have a look at the karma.conf.js file for configuration (e.g. which browsers to use).

The createreferences script starts a server that automatically saves reference PDFs if they don't already exist. You can omit this command if you just want to test for regression.

If you're debugging and want to have visual feedback, you should switch the debug flag to true in tests/runTests.js. This ensures that a new reference PDF will be created on every run. You might also want to disable some of the tests in the tests array.

Dependencies

License

The MIT License (MIT)

Copyright (c) 2015-2019 yWorks GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.