-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// require dependencies | ||
var PDFDocument = require('pdfkit'); | ||
var blobStream = require('blob-stream'); | ||
|
||
// create a document the same way as above | ||
var doc = new PDFDocument(); | ||
|
||
console.log(doc); | ||
// pipe the document to a blob | ||
var stream = doc.pipe(blobStream()); | ||
|
||
// add your content to the document here, as usual | ||
|
||
// get a blob when you're done | ||
doc.end(); | ||
stream.on('finish', function() { | ||
// get a blob you can do whatever you like with | ||
var blob = stream.toBlob('application/pdf'); | ||
|
||
// or get a blob URL for display in the browser | ||
var url = stream.toBlobURL('application/pdf'); | ||
iframe.src = url; | ||
}); | ||
|
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