Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to print a pdf

// use Print.JS
// npm install print-js
$http({      // get request for print pdf
    url: "",
    method: "GET",
    headers: {
        "Content-type": "application/pdf"
    },
    responseType: "arraybuffer"
}).success(function (data, status, headers, config) { // if no error occurs
    var pdfFile = new Blob([data], {
        type: "application/pdf"
    });
    var pdfUrl = URL.createObjectURL(pdfFile); // create pdf url
    //window.open(pdfUrl);
    printJS(pdfUrl); // call Print.JS funtion to print the pdf 
    //var printwWindow = $window.open(pdfUrl);
    //printwWindow.print();
}).error(function (data, status, headers, config) {
    alert("Sorry, something went wrong")
});
 
PREVIOUS NEXT
Tagged: #print #pdf
ADD COMMENT
Topic
Name
1+8 =