dom-to-vector-pdf
A tool for converting DOM elements to vector PDFs using jsPDF, dom-to-svg and svg2pdf.js.
Online Demo
Installation
Basic Usage
Configuration Options
Export Options
Font Options
Lifecycle Hooks
Features
- Converts DOM elements to vector PDFs
- Preserves vector graphics and text
- Supports SVG elements
- Maintains font styles and weights
- Handles complex layouts
Supported styles can be seen in the online demo.
FAQ
-
Fonts: Only TTF is supported. You can use a local import or a CDN URL. Font subsets can be used; a subset with common characters is usually under 1MB. Many online subset tools omit the space character, which can cause rendering to fail. Prefer a library for subsetting. A reference set of common Chinese characters is available at https://github.com/xzboss/PingFangSC (license applies; the repo does not include pre-subset fonts).
-
Pipeline: This library is built on dom-to-svg and svg2pdf. The flow is DOM → SVG → PDF, so there is some SVG serialization overhead, but it usually does not affect performance. Export is typically fast; slowness is often due to large font files — consider subsetting.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT