Last active
April 2, 2019 20:42
-
-
Save learnwell/96a21c7f9b30aeb878c5cbd39971c98f to your computer and use it in GitHub Desktop.
pdfkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://pdfkit.org/demo/browser.html | |
// create a document and pipe to a blob | |
var doc = new PDFDocument(); | |
var stream = doc.pipe(blobStream()); | |
doc.text('hello'); | |
doc.text(lorem, { | |
columns: 3, | |
columnGap: 15, | |
height: 100, | |
width: 465, | |
align: 'justify' | |
}).moveDown(7); | |
doc.text('i was moved down by 7 by the preceding command').moveUp(5); | |
doc.text('i was moved UP by 5 by the preceding command').moveUp(3); | |
doc.text('i was moved UP by 3 by the preceding command').moveUp(1); | |
doc.text('i was moved UP by 1 by the preceding command').moveDown(11); | |
doc.text('1'); | |
doc.text(' 2'); | |
doc.text(' 3'); | |
doc.text(' 4'); | |
doc.text(' 5'); | |
doc.text(' 6'); | |
doc.text(' 5'); | |
doc.text(' 4'); | |
doc.text(' 3'); | |
doc.text(' 2'); | |
doc.text('1'); | |
doc.text('1'); | |
doc.text(' 2'); | |
doc.text(' 3'); | |
doc.text(' 4'); | |
doc.text(' 5').moveUp(5); | |
doc.text(' 5'); | |
doc.text(' 4'); | |
doc.text(' 3'); | |
doc.text(' 2'); | |
doc.text('1'); | |
// end and display the document in the iframe to the right | |
doc.end(); | |
stream.on('finish', function() { | |
iframe.src = stream.toBlobURL('application/pdf'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment