Jspdf: Creating blob from pdf file

Created on 4 Nov 2016  路  6Comments  路  Source: MrRio/jsPDF

var doc = new jsPDF();
doc.text(20,20, 'Hello');

var blob = new Blob([doc], {type: 'application/pdf'});

I tried to create a blob from jsPDF object to include it into a zip file by using jsZIP. However, that method did not work.

Is there a way to get the content of the doc object to use it with blob?

Most helpful comment

var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(element, function () {
    var blob = pdf.output('blob');
});

cheers

All 6 comments

var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(element, function () {
    var blob = pdf.output('blob');
});

cheers

Thank you @mnewmedia.

var blob = pdf.output('blob'); is all I needed.

Did it work?

I am trying below code:

var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#printView')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};

        var blob = pdf.output('blob');

but it is not working. I need to get blob object for pdf and send to API. Getting blob for empty pdf.

Did it work?

I am trying below code:

var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#printView')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};

        var blob = pdf.output('blob');

but it is not working. I need to get blob object for pdf and send to API. Getting blob for empty pdf.

same problem:(

Did it work?

I am trying below code:

var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#printView')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};

        var blob = pdf.output('blob');

but it is not working. I need to get blob object for pdf and send to API. Getting blob for empty pdf.

Same Problem

Did it work?

I am trying below code:

var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#printView')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};

        var blob = pdf.output('blob');

but it is not working. I need to get blob object for pdf and send to API. Getting blob for empty pdf.

Same here, not working for. Can someone help me out

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andmaltes picture andmaltes  路  4Comments

0721Betty picture 0721Betty  路  4Comments

MelanieCroce picture MelanieCroce  路  4Comments

allenksun picture allenksun  路  3Comments

tarekis picture tarekis  路  4Comments