How to open jsPDF in modal
I have this code to generate my PDF files using jsPDF library:
// 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["client_id"],10,10);
doc.text("Name: " + row["name"],10,14);
doc.text("Gender: " + row["gender"], 10, 18);
doc.text("Company: " + row["company"], 10, 22);
//doc.save("a4.pdf");
doc.autoPrint();
doc.output("dataurlnewwindow");
¿It´s possible to open in modal window?
Using this script:
$.ajax(
type : "POST",
url : getPrintablePDF,
dataType : "json",
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(params),
success : function(data)
var myResponse = eval(data);
$("<iframe />") // create an iframe
// add the source
.attr('src', 'data:application/pdf;base64,' + myResponse.base64EncodedResponse)
.appendTo('.modal-body'); // append to modal body or wherever you want
);
Thank you!
javascript jspdf
add a comment |
I have this code to generate my PDF files using jsPDF library:
// 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["client_id"],10,10);
doc.text("Name: " + row["name"],10,14);
doc.text("Gender: " + row["gender"], 10, 18);
doc.text("Company: " + row["company"], 10, 22);
//doc.save("a4.pdf");
doc.autoPrint();
doc.output("dataurlnewwindow");
¿It´s possible to open in modal window?
Using this script:
$.ajax(
type : "POST",
url : getPrintablePDF,
dataType : "json",
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(params),
success : function(data)
var myResponse = eval(data);
$("<iframe />") // create an iframe
// add the source
.attr('src', 'data:application/pdf;base64,' + myResponse.base64EncodedResponse)
.appendTo('.modal-body'); // append to modal body or wherever you want
);
Thank you!
javascript jspdf
How to integrate it
– c3media
Jun 8 '17 at 21:01
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
1
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
I have this code to generate my PDF files using jsPDF library:
// 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["client_id"],10,10);
doc.text("Name: " + row["name"],10,14);
doc.text("Gender: " + row["gender"], 10, 18);
doc.text("Company: " + row["company"], 10, 22);
//doc.save("a4.pdf");
doc.autoPrint();
doc.output("dataurlnewwindow");
¿It´s possible to open in modal window?
Using this script:
$.ajax(
type : "POST",
url : getPrintablePDF,
dataType : "json",
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(params),
success : function(data)
var myResponse = eval(data);
$("<iframe />") // create an iframe
// add the source
.attr('src', 'data:application/pdf;base64,' + myResponse.base64EncodedResponse)
.appendTo('.modal-body'); // append to modal body or wherever you want
);
Thank you!
javascript jspdf
I have this code to generate my PDF files using jsPDF library:
// 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["client_id"],10,10);
doc.text("Name: " + row["name"],10,14);
doc.text("Gender: " + row["gender"], 10, 18);
doc.text("Company: " + row["company"], 10, 22);
//doc.save("a4.pdf");
doc.autoPrint();
doc.output("dataurlnewwindow");
¿It´s possible to open in modal window?
Using this script:
$.ajax(
type : "POST",
url : getPrintablePDF,
dataType : "json",
contentType : 'application/json; charset=utf-8',
data : JSON.stringify(params),
success : function(data)
var myResponse = eval(data);
$("<iframe />") // create an iframe
// add the source
.attr('src', 'data:application/pdf;base64,' + myResponse.base64EncodedResponse)
.appendTo('.modal-body'); // append to modal body or wherever you want
);
Thank you!
javascript jspdf
javascript jspdf
edited Jun 8 '17 at 21:00
c3media
asked Jun 8 '17 at 20:31
c3mediac3media
318
318
How to integrate it
– c3media
Jun 8 '17 at 21:01
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
1
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
How to integrate it
– c3media
Jun 8 '17 at 21:01
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
1
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
How to integrate it
– c3media
Jun 8 '17 at 21:01
How to integrate it
– c3media
Jun 8 '17 at 21:01
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
1
1
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
2 Answers
2
active
oldest
votes
I had a similar requirement. Since the modal was not able to decode jdpdf's dataUristring directly, I loaded jspdf in an iframe and then opened iframe in a modal.
$('.modal').on('shown.bs.modal',function()
$(this).find('iframe').html("").attr("src", pdf.output('datauristring'));
)
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
function print_row()
//Logic to print the item
var YourVar= My var value;
// 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(orientation: 'portrait', unit: 'mm', format: [210, 80]);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(16);
doc.setFontType("italic");
doc.text("Your text "+ YourVar, 4, 10);
doc.autoPrint();
// doc.save("a4.pdf");
// this opens a new popup, after this the PDF opens the print window view
// doc.output("bloburi");
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");
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44445032%2fhow-to-open-jspdf-in-modal%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had a similar requirement. Since the modal was not able to decode jdpdf's dataUristring directly, I loaded jspdf in an iframe and then opened iframe in a modal.
$('.modal').on('shown.bs.modal',function()
$(this).find('iframe').html("").attr("src", pdf.output('datauristring'));
)
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
I had a similar requirement. Since the modal was not able to decode jdpdf's dataUristring directly, I loaded jspdf in an iframe and then opened iframe in a modal.
$('.modal').on('shown.bs.modal',function()
$(this).find('iframe').html("").attr("src", pdf.output('datauristring'));
)
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
I had a similar requirement. Since the modal was not able to decode jdpdf's dataUristring directly, I loaded jspdf in an iframe and then opened iframe in a modal.
$('.modal').on('shown.bs.modal',function()
$(this).find('iframe').html("").attr("src", pdf.output('datauristring'));
)
I had a similar requirement. Since the modal was not able to decode jdpdf's dataUristring directly, I loaded jspdf in an iframe and then opened iframe in a modal.
$('.modal').on('shown.bs.modal',function()
$(this).find('iframe').html("").attr("src", pdf.output('datauristring'));
)
edited Feb 8 '18 at 18:21
answered Feb 8 '18 at 16:55
prafiprafi
8115
8115
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15
add a comment |
function print_row()
//Logic to print the item
var YourVar= My var value;
// 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(orientation: 'portrait', unit: 'mm', format: [210, 80]);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(16);
doc.setFontType("italic");
doc.text("Your text "+ YourVar, 4, 10);
doc.autoPrint();
// doc.save("a4.pdf");
// this opens a new popup, after this the PDF opens the print window view
// doc.output("bloburi");
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");
;
add a comment |
function print_row()
//Logic to print the item
var YourVar= My var value;
// 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(orientation: 'portrait', unit: 'mm', format: [210, 80]);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(16);
doc.setFontType("italic");
doc.text("Your text "+ YourVar, 4, 10);
doc.autoPrint();
// doc.save("a4.pdf");
// this opens a new popup, after this the PDF opens the print window view
// doc.output("bloburi");
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");
;
add a comment |
function print_row()
//Logic to print the item
var YourVar= My var value;
// 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(orientation: 'portrait', unit: 'mm', format: [210, 80]);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(16);
doc.setFontType("italic");
doc.text("Your text "+ YourVar, 4, 10);
doc.autoPrint();
// doc.save("a4.pdf");
// this opens a new popup, after this the PDF opens the print window view
// doc.output("bloburi");
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");
;
function print_row()
//Logic to print the item
var YourVar= My var value;
// 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(orientation: 'portrait', unit: 'mm', format: [210, 80]);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(16);
doc.setFontType("italic");
doc.text("Your text "+ YourVar, 4, 10);
doc.autoPrint();
// doc.save("a4.pdf");
// this opens a new popup, after this the PDF opens the print window view
// doc.output("bloburi");
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");
;
answered Nov 11 '18 at 7:13
c3mediac3media
318
318
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44445032%2fhow-to-open-jspdf-in-modal%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How to integrate it
– c3media
Jun 8 '17 at 21:01
Hi - is the jspdf code sample running on the server? It is certainly possible to show a server-based pdf in a modal. So what is the problem that you are having please ?
– Vanquished Wombat
Jun 13 '17 at 10:50
1
Thank you, question resolved!
– c3media
Nov 7 '17 at 11:18
How about noting the fix - even if it was a mistake in the code please explain so we know.
– Vanquished Wombat
Nov 7 '17 at 15:12
Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html
– c3media
Nov 11 '18 at 7:15