canvas2svg VS svg2pdf.js

Compare canvas2svg vs svg2pdf.js and see what are their differences.

canvas2svg

Translates HTML5 Canvas draw commands to SVG (by gliffy)

svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts (by yWorks)
Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
canvas2svg svg2pdf.js
3 5
670 625
2.5% 3.1%
0.0 5.8
5 months ago 17 days ago
JavaScript TypeScript
MIT License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

canvas2svg

Posts with mentions or reviews of canvas2svg. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-11-13.
  • Forking Chrome to Turn HTML into SVG
    8 projects | news.ycombinator.com | 13 Nov 2022
    Reminds me of https://github.com/gliffy/canvas2svg at a different level of abstraction.

    I believe PDF.js incorporated some form canvas2svg to try and get a SVG backend working which would allow high resolution printing to PDF but not sure where that's at. I believe printing through PDF.js is blurry due to memory constraints since with normal canvas pdf pages just end up as bitmaps sent to the printer.

    SVG ends up staying vector through Chromiums print pipeline resulting in much less memory usage while having much higher dpi final output. I would imagine this is due to SVG being turned into Skia drawing commands that end up as PDF that then gets printed through PDFium?

  • Snapshot of planetary positions at a given date. Custom code, 10 tool changes, plotted on a 3D printer.
    1 project | /r/PlotterArt | 27 Oct 2021
    I used JavaScript to generate planetary positions and orbit paths as SVG with canvas2svg by following this for the mathematical side https://ssd.jpl.nasa.gov/planets/approx_pos.html
  • Essential SVG tools
    9 projects | dev.to | 15 Apr 2021
    Canvas2SVG - I have a feeling I'll get to know this library well someday. Apache Batik - I used it quite a bit in the early days but it never took root in my toolchain. SVGJS It offers compelling shortcuts, I'm just a fan of vanilla JS. This also goes for SNAP SVG

svg2pdf.js

Posts with mentions or reviews of svg2pdf.js. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-01-13.
  • Is node the right choice for HTML to PDF conversion?
    6 projects | /r/node | 13 Jan 2023
    You should check out Vercel's Satori package. You can generate SVGs from JSX without a chromium instance. Pair that with something like https://github.com/yWorks/svg2pdf.js/ and you might be onto something.
  • Forking Chrome to Turn HTML into SVG
    8 projects | news.ycombinator.com | 13 Nov 2022
  • What's a good way to deliver printable reports?
    3 projects | /r/sveltejs | 6 Aug 2022
    If you need to print to exact dimensions, you MUST use PDF. This was what i needed, so I draw everything to an SVG, and made sure that my units were in "pt" (that is 1px = 1/72inch). When creating the PDF, I specified that the units were in "pt" and used https://github.com/yWorks/svg2pdf.js/ to convert the SVG. Note that this has major disadvantages. SVG does not support word wrap by default; you'll have to write your own. You'll also have to get users to specify a paper size in your app. Again, test, test, test. If you want to preview the PDF, not all browsers can display PDF natively (looking at you Android)! Some browsers won't print exact size even in PDF (Android). Some browsers will reduce page margins if printing from an inline iframe preview (Safari). You need annoying workarounds. Like downloading instead of previewing the file on Android, or making sure to always open a new tab on Safari.
  • Creating a PDF
    2 projects | /r/sveltejs | 2 Aug 2022
    I used it with https://github.com/yWorks/svg2pdf.js/ which makes it easy to draw diagrams too.
  • Guest WiFi using a QR code
    6 projects | news.ycombinator.com | 12 Jul 2022
    Hmm, after tinkering around a bit, I think according to https://github.com/yWorks/svg2pdf.js/issues/82 , the mask element in the giraffe SVGs is not supported in the PDF converter. It is just dropped, leafing the qraffe rather qr-less.

    But I sadly know neither svg enough to think up an alternative approach, or a JS/TS dev enough to see if there are other libraries.

What are some alternatives?

When comparing canvas2svg and svg2pdf.js you can also consider the following projects:

resvg - An SVG rendering library.

pdf-lib - Create and modify PDF documents in any JavaScript environment

imagetracerjs - Simple raster image tracer and vectorizer written in JavaScript.

jsPDF - Client-side JavaScript PDF generation for everyone.

satori - Enlightened library to convert HTML and CSS to SVG

dungeonz - Everything for the game Rogueworld. [Moved to: https://github.com/Arcanorum/rogueworld]

svg_crop - Remove blank space from around any SVG instantly.

react-pdf - 📄 Create PDF files using React

lib2geom

webpack - A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.

TypeStat - Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫