All Projects → yWorks → Svg2pdf.js

yWorks / Svg2pdf.js

Licence: mit
A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Svg2pdf.js

Openpdf
OpenPDF is a free Java library for creating and editing PDF files with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository. ⛺
Stars: ✭ 2,174 (+841.13%)
Mutual labels:  hacktoberfest, pdf
Offline Qr Code
📱 Browser add-on allowing you to quickly generate a QR code offline with the URL of the open tab or other text!
Stars: ✭ 193 (-16.45%)
Mutual labels:  hacktoberfest, browser
Svg utils
Python tools to create and manipulate SVG files
Stars: ✭ 169 (-26.84%)
Mutual labels:  hacktoberfest, svg
Cast Sh
📟 An instance of your terminal in your browser
Stars: ✭ 151 (-34.63%)
Mutual labels:  hacktoberfest, browser
Cep Promise
Busca por CEP integrado diretamente aos serviços dos Correios, ViaCEP e outros (Node.js e Browser)
Stars: ✭ 2,483 (+974.89%)
Mutual labels:  hacktoberfest, browser
Openlinkwith
Open the current webpage you have in another app. Magic! 🔮
Stars: ✭ 158 (-31.6%)
Mutual labels:  hacktoberfest, browser
Supertinyicons
Under 1KB each! Super Tiny Icons are miniscule SVG versions of your favourite website and app logos
Stars: ✭ 13,177 (+5604.33%)
Mutual labels:  hacktoberfest, svg
React Content Loader
⚪ SVG-Powered component to easily create skeleton loadings.
Stars: ✭ 11,830 (+5021.21%)
Mutual labels:  hacktoberfest, svg
React Native Pdfview
📚 PDF viewer for React Native
Stars: ✭ 198 (-14.29%)
Mutual labels:  hacktoberfest, pdf
Paper
Hassle-free HTML to PDF conversion abstraction library.
Stars: ✭ 196 (-15.15%)
Mutual labels:  pdf, conversion
Pyecharts Snapshot
renders the output of pyecharts as png, jpeg, gif, svg, eps, pdf and raw base64
Stars: ✭ 142 (-38.53%)
Mutual labels:  svg, pdf
Web Worker Proxy
A better way of working with web workers
Stars: ✭ 218 (-5.63%)
Mutual labels:  hacktoberfest, browser
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (-39.83%)
Mutual labels:  svg, pdf
Brain.js
brain.js is a GPU accelerated library for Neural Networks written in JavaScript.
Stars: ✭ 12,358 (+5249.78%)
Mutual labels:  hacktoberfest, browser
Educative.io Downloader
📖 This tool is to download course from educative.io for offline usage. It uses your login credentials and download the course.
Stars: ✭ 139 (-39.83%)
Mutual labels:  hacktoberfest, pdf
Node Webkitgtk
webkitgtk bindings for 🚀 Node.js
Stars: ✭ 185 (-19.91%)
Mutual labels:  pdf, browser
Pokeapi Js Wrapper
PokeAPI browser wrapper, fully async with built-in cache
Stars: ✭ 129 (-44.16%)
Mutual labels:  hacktoberfest, browser
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (-41.99%)
Mutual labels:  svg, pdf
Python Scripts
Collection of Various Python Script's.💻
Stars: ✭ 195 (-15.58%)
Mutual labels:  hacktoberfest, browser
Shields
Concise, consistent, and legible badges in SVG and raster format
Stars: ✭ 15,716 (+6703.46%)
Mutual labels:  hacktoberfest, svg

svg2pdf.js

NPM version Continous Integration for svg2pdf.js

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

Give it a trial: online playground.

Installation

You can get svg2pf.js via npm:

npm install svg2pdf.js jspdf --save
# or
yarn add svg2pdf.js jspdf

Since version 2.x, this repository no longer depends on a forked jsPDF but can be used with original MrRio/jsPDF.

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

import { jsPDF } from 'jspdf'
import 'svg2pdf.js'

const doc = new jsPDF()

const element = document.getElementById('svg')
doc
  .svg(element, {
    x,
    y,
    width,
    height
  })
  .then(() => {
    // save the created pdf
    doc.save('myPDF.pdf')
  })

Have a look at the typings file for detailed documentation.

Other module formats

Importing is also possible via requirejs:

require.config({
  baseUrl: './node_modules'
});
require([
  'svg2pdf.js/dist/svg2pdf.umd.min',
  'jspdf/dist/jspdf.umd.min'
], (svg2pdf, jsPDF) => {...});

or script-tag:

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

Concerning custom fonts and non US-ASCII characters

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

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 necessary information.

Please stick to our Code of Conduct.

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 test 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-unit

The tests use the Karma framework and run in a captured (headless) browser.

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 test/unit/all.spec.js. This ensures that a new reference PDF will be created on every run. You might also want to disable some tests in the test/common/tests array.

Dependencies

License

The MIT License (MIT)

Copyright (c) 2015-2020 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].