All Projects → joshua-gould → Canvas2pdf

joshua-gould / Canvas2pdf

Licence: mit
Export your HTML canvas to PDF

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Canvas2pdf

Pdfmerge
Command-line utility for merging, splicing, and rotating PDF documents.
Stars: ✭ 88 (-8.33%)
Mutual labels:  pdf
Books
cs books
Stars: ✭ 93 (-3.12%)
Mutual labels:  pdf
Remarks
Extract highlights, scribbles, and annotations from PDFs marked with the reMarkable tablet. Export to Markdown, PDF, PNG, and SVG
Stars: ✭ 94 (-2.08%)
Mutual labels:  pdf
Official Bash Logo
Everything you need to start using the official GNU Bash logo
Stars: ✭ 89 (-7.29%)
Mutual labels:  pdf
Vega
A visualization grammar.
Stars: ✭ 9,554 (+9852.08%)
Mutual labels:  canvas
Puppeteer Dart
A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
Stars: ✭ 92 (-4.17%)
Mutual labels:  pdf
Vectorgraphics2d
Graphics2D implementations to export various vector file formats
Stars: ✭ 87 (-9.37%)
Mutual labels:  pdf
Airinggo
🐈 基于 JS 的五子棋 AI 实现
Stars: ✭ 95 (-1.04%)
Mutual labels:  canvas
Portablesigner2
PortableSigner - A Commandline and GUI Tool to digital sign PDF files with X.509 certificates
Stars: ✭ 92 (-4.17%)
Mutual labels:  pdf
Android Databinding
this is the databinding framework of android . help to binding data to the view.
Stars: ✭ 93 (-3.12%)
Mutual labels:  pdf
Waveview
A wave view of android,can be used as progress bar.
Stars: ✭ 1,294 (+1247.92%)
Mutual labels:  canvas
Fun Photo Combine
一个有趣的图片合成工具(生成的图片在QQ缩略图与大图表现不同)
Stars: ✭ 90 (-6.25%)
Mutual labels:  canvas
Sunwell
Canvas-based high quality Hearthstone card renderer
Stars: ✭ 93 (-3.12%)
Mutual labels:  canvas
React Tint
A React component that applies image processing filters to an image using Processing
Stars: ✭ 89 (-7.29%)
Mutual labels:  canvas
Fe Daily Record
📚前端书籍汇集点 + 每日好文推荐 + 公开课学习资料 + 各种大会资料
Stars: ✭ 94 (-2.08%)
Mutual labels:  canvas
Canvacord
Powerful image manipulation tool to manipulate images easily.
Stars: ✭ 87 (-9.37%)
Mutual labels:  canvas
Kanvas
Make canvas easier to use in Kotlin 😊
Stars: ✭ 93 (-3.12%)
Mutual labels:  canvas
Bouncing Balls
Bouncing balls simulation using plain JavaScript
Stars: ✭ 96 (+0%)
Mutual labels:  canvas
Officeproducer
Produce doc/docx/pdf format from doc/docx template
Stars: ✭ 95 (-1.04%)
Mutual labels:  pdf
My Animate
使用 HTML5 / Canvas / CSS3 制作各种动画效果
Stars: ✭ 93 (-3.12%)
Mutual labels:  canvas

Canvas2PDF

Canvas2PDF exports an HTML canvas to PDF. In other words, this library lets you build a PDF document using the canvas API.

How it works

We create a mock 2d canvas context. Use the canvas context like you would on a normal canvas. As you call methods, we use PDFKit to generate a PDF document.

Browser Usage

//Create a new PDF canvas context.
var ctx = new canvas2pdf.PdfContext(blobStream());

//draw your canvas like you would normally
ctx.fillStyle='yellow';
ctx.fillRect(100,100,100,100);
// more canvas drawing, etc...

//convert your PDF to a Blob and save to file
ctx.stream.on('finish', function () {
    var blob = ctx.stream.toBlob('application/pdf');
    saveAs(blob, 'example.pdf', true);
});
ctx.end();

Node Usage

PDFDocument = require('pdfkit')
const fs = require('fs')
const canvas2pdf = require('canvas2pdf')

const file = fs.createWriteStream('example.pdf')
//Create a new PDF canvas context.
const ctx = new canvas2pdf.PdfContext(file)

//draw your canvas like you would normally
ctx.fillStyle = 'yellow'
ctx.fillRect(100, 100, 100, 100)
// more canvas drawing, etc...

ctx.stream.on('finish', function () {
  file.end()
})
ctx.end()

Dependencies

Using with node.js

canvas2pdf works with node.js. Note that neither a DOM or canvas library is needed.

Interactive Browser Demo

Open Demo

Notes

  • Inspired by Canvas2Svg
  • Calling fill and then stroke consecutively only executes fill
  • Some canvas 2d context methods are not implemented yet (e.g. setTransform and arcTo)

Status

Build Status

License

MIT

Developer Dependencies

  • Ghostscript and GraphicsMagick are required for running tests
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].