Loading jsPDF in modal window

QuestionsLoading jsPDF in modal window
C3media asked 7 years ago

Hello,

I have this to generate PDF using library jsPDF:

<script type="text/javascript">
print = function () {
var rowid = jQuery("#list1").jqGrid("getGridParam","selrow");
var row = $("#list1").getRowData(rowid);

// JSPDF, docs: http://rawgit.com/MrRio/jsPDF/master/docs/global.html

// Default export is a4 paper, portrait, using milimeters for units
var doc = new jsPDF()

// set font size
doc.setFontSize(12);

doc.text("Invoice #" + row["id"],10,10);
doc.text("Cliente: " + row["customer"],10,14);
doc.text("Total: " + row["total"], 10, 18);
doc.text("Fecha: " + row["due_date"], 10, 22);
//doc.save("a4.pdf");
doc.autoPrint();
doc.output("dataurlnewwindow");

// this opens a new popup, after this the PDF opens the print window view

});
</script>

And this buttton to call function:

$buttons_html = "<button onclick='print()' class='fancybox' data-fancybox-type='iframe' >Print</>";

Show me error and not load file .pdf

Thank you!

3 Answers
Abu Ghufran answered 7 years ago

Working demo code attached. Review line 117, 142-166
https://gist.github.com/gridphp/dd5c7382e8eb859ab0716ca481509570

C3media answered 7 years ago

This thread was partially resolved using window.open so:

window.open(doc.output('bloburl'), '_blank',"toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes,top=200,left=350,width=600,height=400");

I'll try to add custom code in jsPDF.js library in uri parameters.

Thank you!

dheeraj kumar answered 5 years ago

This will be open in new tab with complete hight and width

window.open(doc.output(‘bloburl’), ‘_blank’);

Your Answer

15 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?