Pdfkit: PdfKit generate pdf in server side but not send it to client using browserify

Created on 8 Jun 2015  路  4Comments  路  Source: foliojs/pdfkit

Hi friend,
I am going to use http://pdfkit.org/demo/browser.html to generate pdf in iframe but it gives error

this._blob = new Blob(this._chunks, {
TypeError: undefined is not a function
at BlobStream.toBlob (/home/hacker201501/Desktop/cocreate/node_modules/blob-stream/index.js:33:18)
at BlobStream. (/home/hacker201501/Desktop/cocreate/app/controllers/designs.js:275:17)
at BlobStream.EventEmitter.emit (events.js:129:20)
at finishMaybe (_stream_writable.js:446:14)
at endWritable (_stream_writable.js:455:3)
at BlobStream.Writable.end (_stream_writable.js:422:5)
at PDFDocument.onend (_stream_readable.js:501:10)
at PDFDocument.g (events.js:199:16)
at PDFDocument.EventEmitter.emit (events.js:129:20)
at _stream_readable.js:898:16

this is my code
stream.on('finish', function() {
var blob, url;
blob = stream.toBlob('application/pdf');
url = stream.toBlobURL('application/pdf');
console.log(url)
return iframe.src = url;
});

Most helpful comment

@costas1379 or @nqgajanan did you find any solution for your problem?

All 4 comments

Any progress on this issue?

+1

Hello I got a similar error:
My code:

var pdfDoc = require("pdfkit");
var doc = new pdfDoc();
var blobStream = require("blob-stream");
var stream = doc.pipe(blobStream());
// some document stuff here e.g doc.text()
doc.end()
stream.on("finish",function(){
        var blob = stream.toBlob("application/pdf");
        // use blob here
});

This is the error Im getting:

    this._blob = new Blob(this._chunks, {
                 ^

TypeError: Blob is not a function
    at BlobStream.toBlob (.../node_modules/blob-stream/index.js:33:18)
    at BlobStream.<anonymous> (.../make-invoice.js:269:27)
    at emitNone (events.js:72:20)
    at BlobStream.emit (events.js:166:7)
    at finishMaybe (_stream_writable.js:482:14)
    at endWritable (_stream_writable.js:492:3)
    at BlobStream.Writable.end (_stream_writable.js:457:5)
    at PDFDocument.onend (_stream_readable.js:498:10)
    at PDFDocument.g (events.js:260:16)
    at emitNone (events.js:67:13)

@costas1379 or @nqgajanan did you find any solution for your problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tm2josep picture tm2josep  路  5Comments

stephen-last picture stephen-last  路  4Comments

raesche picture raesche  路  4Comments

alFReD-NSH picture alFReD-NSH  路  4Comments

huy-nguyen picture huy-nguyen  路  4Comments