How to open jsPDF in modal










2















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!










share|improve this question
























  • 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















2















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!










share|improve this question
























  • 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













2












2








2








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















0














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'));
)





share|improve this answer

























  • Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html

    – c3media
    Nov 11 '18 at 7:15


















0














 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");
;





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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'));
    )





    share|improve this answer

























    • Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html

      – c3media
      Nov 11 '18 at 7:15















    0














    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'));
    )





    share|improve this answer

























    • Resolved using // JSPDF, docs: rawgit.com/MrRio/jsPDF/master/docs/global.html

      – c3media
      Nov 11 '18 at 7:15













    0












    0








    0







    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'));
    )





    share|improve this answer















    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'));
    )






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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

















    • 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













    0














     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");
    ;





    share|improve this answer



























      0














       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");
      ;





      share|improve this answer

























        0












        0








        0







         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");
        ;





        share|improve this answer













         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");
        ;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 '18 at 7:13









        c3mediac3media

        318




        318



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Crossroads (UK TV series)

            ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế