Skip to content

sajumani/p5.js-pdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p5.js-pdf

A simple PDF export module for p5.js.

Online Demo: https://zenozeng.github.io/p5.js-pdf/demo/

Usage

var pdf;

function setup() {
    createCanvas(640, 640);

    pdf = new p5.PDF(); // should be called after #defaultCanvas is ready
}

function draw() {
    // draw something here

    // manually add new page
    // pdf.nextPage();

    // capture current frame
    pdf.capture();
}

setTimeout(function() {
    noLoop();
    window.location.href = pdf.toObjectURL();
}, 5000);

Full Documentation

https://zenozeng.github.io/p5.js-pdf/doc/p5.PDF.html

FAQ

Browser Compatibility

Basically, it should work in the latest versions of evergreen browsers and IE10+. Note that even in IE11, due to the lack of support to download attrbute, pdf.save(filename) may simply open PDF directly instead.

Why not use PNG by default?

Chrome may crash when there are too many PNG in jsPDF.

See also:

However, if you must, you can use new p5.PDF({imageType: 'PNG'}).

License (MIT)

Copyright (c) 2015 Zeno Zeng.

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.

This program incorporates work covered by the following copyright and permission notices:

  • jsPDF (MIT)

    Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
    
  • jspdf.plugin.addimage.js (MIT)

    jsPDF addImage plugin

    Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/
                  2013 Chris Dowling, https://github.com/gingerchris
                  2013 Trinh Ho, https://github.com/ineedfat
                  2013 Edwin Alejandro Perez, https://github.com/eaparango
                  2013 Norah Smith, https://github.com/burnburnrocket
                  2014 Diego Casorran, https://github.com/diegocr
                  2014 James Robb, https://github.com/jamesbrobb
    
  • jspdf.plugin.png_support.js (MIT)

    jsPDF PNG PlugIn

    Copyright (c) 2014 James Robb, https://github.com/jamesbrobb
    
  • zlib.js (from pdf.js) (MIT)

    Copyright (c) 2011 Mozilla Foundation
    
    Contributors: Andreas Gal <[email protected]>
                  Chris G Jones <[email protected]>
                  Shaon Barman <[email protected]>
                  Vivien Nicolas <[email protected]>
                  Justin D'Arcangelo <[email protected]>
                  Yury Delendik
    
  • PNG.js (MIT)

    Copyright (c) 2011 Devon Govett
    

Build

sudo npm install -g browserify
sudo npm install -g jsdoc
npm run build

Links

About

A simple PDF export module for p5.js.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.7%
  • HTML 0.3%