I'm pretty much new into this library but i could not find a method which would allow me to generate a pdf from a pdf dataUrl.
Sample dataUrl: data:application/pdf;base64,JVBERi0xLjUNCiXx+ff2DQolMy4zDQo2IDAgb2JqDQo8PA0KL0JpdHNQZXJDb21wb25lbnQgOCANCi9Db2xvclNwYWNlIC9EZXZpY2VSR0IgDQovRmlsdGVyIFsgL0ZsYXRlRGVjb2RlIC9EQ1REZWNvZGUgXQ0KDQovSGVpZ2h0IDIyMDAgDQovTGVuZ3RoIDcgMCBSIA0KL05hbWUgL0ltYWdlUGFydF8wIA0KL1N1YnR5cGUgL0ltYWdlIA0
Here is a brief explanation of my scenario:
From whatever i found on docs, i believe that i could something like:
const { jsPDF } = require("jspdf");
const doc = new jsPDF();
Once i have converted the dataUrl into an image i can use **add page** method to add it to the pdf
doc.save()
Secondly, it would be off great help if you could give some clear examples along with the api methods in docs.
Sorry, but from your description I don't fully understand what you want to achieve. Do you want to convert a PDF file to a PNG image or to you want to convert a PNG image to a PDF? Or do you want to read a PDF file, add a PNG image and save it again? Please clarify.
Please also note that jsPDF does not support parsing or modifying existing PDF files.
@HackbrettXXX Thanks a lot for the swift response 馃檹 . I apologize for the lack of clarity in my previous comment.
So here is what i want to do:
const reader = new FileReader();
reader.readAsDataURL(file);
data:application/pdf;base64,JVBERi0xLjUNCiXx+ff2DQolMy4zDQo2IDAgb2JqDQo8PA0KL0JpdHNQZXJDb21wb25lbnQgOCANCi9Db2xvclNwYWNlIC9EZXZpY2VSR0IgDQovRmlsdGVyIFsgL0ZsYXRlRGVjb2RlIC9EQ1REZWNvZGUgXQ0KDQovSGVpZ2h0IDIyMDAgDQovTGVuZ3RoIDcgMCBSIA0KL05hbWUgL0ltYWdlUGFydF8wIA0KL1N1YnR5cGUgL0ltYWdlIA0.Please let me know whether there is a way to achieve this with jsPDF
Unfortunately, this is not possible with jsPDF. JsPDF cannot parse existing files and cannot convert a PDF file to an image.