Skip to content

Insert SVG into a PDF document created with PDFKit

Notifications You must be signed in to change notification settings

sdllc/SVG-to-PDFKit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG-to-PDFKit

Insert SVG into a PDF document created with PDFKit.

####Use:

SVGtoPDF(doc, svg, x, y, options);

####Parameters:

doc [PDFDocument] = the PDF document created with PDFKit
svg [SVGElement or string] = the SVG object or XML code
x, y [number] = the position where the SVG will be added
options [Object] = not documented yet

####Demo:

    https://alafr.github.io/SVG-to-PDFKit/demo.htm

####Supported:

  • shapes: rect, circle, path, ellipse, line, polyline, polygon
  • special elements: use, nested svg
  • text elements: text, tspan, textPath
  • text attributes: x, y, dx, dy, rotate, text-anchor, textLength, word-spacing, letter-spacing, font-size
  • styling: with attributes only
  • colors: fill, stroke & color (rgb, rgba, hex, string), fill-opacity, stroke-opacity & opacity
  • units: all standard units
  • transformations: transform, viewBox & preserveAspectRatio attributes
  • clip paths & masks

####Unsupported:

  • css: style element and inline style
  • gradients (#16)
  • other things I don't even know they exist

####Warning:

  • There are bugs, please send issues and/or pull requests.

####Other useful projects:

  • PDFKit, the JavaScript PDF generation library for Node and the browser
  • If you want to insert SVGs into a PDFKit document there is also svgkit with more supported features.
  • For the opposite conversion, from PDF to SVG, you can use Mozilla's PDF.js.

About

Insert SVG into a PDF document created with PDFKit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.1%
  • HTML 8.9%