PrintJS - JSON Multiple Pages - JSFiddle - JSFiddle
HTML
<script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app">
<button id="fetch-and-print-data" type="button">
Fetch and Print JSON Data
</button>
</div>
JavaScript
function fetchAndPrintData() {
/*axios.get('https://api.github.com/repos/crabbly/print.js/stargazers?per_page=80')
.then(response => {
printJS({printable: response.data, type: 'pdf'});
})
*/
$.http({
url: "http://www.pdf995.com/samples/pdf.pdf",
method: "GET",
headers: { "Content-type": "application/pdf"},
responseType: "arraybuffer"
}).success(function (data, status, headers, config) {
var pdfFile = new Blob([data], {type: "application/pdf"});
var pdfUrl = URL.createObjectURL(pdfFile);
//window.open(pdfUrl);
printJS(pdfUrl);
//var printwWindow = $window.open(pdfUrl);
//printwWindow.print();
}).error(function (data, status, headers, config) {
alert("Sorry, something went wrong")
});
}
document.getElementById ("fetch-and-print-data").addEventListener ("click", fetchAndPrintData);