question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating blob from pdf file

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

8reactions
pablomaurercommented, Nov 4, 2016
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(element, function () {
    var blob = pdf.output('blob');
});

cheers

1reaction
vinodsamycommented, Jun 19, 2019

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:(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properly Create and Serve PDF Blob via HTML5 File and URL ...
done(function(data){ var file = new Blob([data], {type:'application/pdf'}), url = URL.createObjectURL(file), _iFrame = document.createElement(' ...
Read more >
JavaScript: Save BLOB as PDF File - ASPSnippets
In this article I will explain with an example, how to save BLOB (Binary Data) as PDF file using JavaScript. The PDF file...
Read more >
Convert PDF Form to Blob, Base64 URL, or Raw PDF
Download a fillable PDF form as a PDF file or get the form as Blob, Base64 URL, or raw PDF to preview it...
Read more >
Open & Display PDF from Blob Using JavaScript - PSPDFKit
Open and Display PDFs from a Blob Using JavaScript ... const documentBlobObjectUrl = URL.createObjectURL(blob); PSPDFKit.load({ document: documentBlobObjectUrl }) ...
Read more >
How to create PDF blob from bytes, string, data uri, html
I've tried converting a JPEG blob to a string or array of bytes and back again, and haven't had any success. function setImage(po)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found