mercredi 10 juin 2015

Javascript Print() sometimes firing print layout/paper size options and sometimes doesn't

This is the exact same function I am using in two different parts of my application. (Which is an Ember application). However, in the first instance, when you fire this function, the application opens a new window with the html data on it, then opens a print dialog with the options layout and paper size.

In the second instance, these options are not included. Why would this happen? Or, if there is a better way to format for printing, what am I doing wrong?

  printPreview: function(){ //For Printing Issue Document
        var data = $('#editDoc').editable('getHTML', false, true);
        data = '<div class="froala-view">' + data + '</div>';
        data = '<link rel="stylesheet" href="styles/froala_editor.css">    <link rel="stylesheet" href="styles/froala_content.css"><link rel="stylesheet" href="styles/froala_style.css">' + data;
        // debugger


        var printWindow = window.open('', '_blank','width=825,height=590'); 
        printWindow.document.write(data); 
        printWindow.document.close(); 
        setTimeout(function() { //content loaded after 1 sec print will invoke
            printWindow.print();
           }, 1000);

    },




Aucun commentaire:

Enregistrer un commentaire