Sharing Top Content from the Angular-sphere.

Download and then Print PDF File in AngularJS

  • With the simple sample code snippet, you can easily download & print pdf by using angularJS.
  • Sometime developer need to download PDF file and print that pdf document.
  • Posted on September 29, 2016 Author Sohel Rana
  • Categories: AngularJS , Code Area , Java Script
  • PHP Programmer, Software Engineer & Technology lover

Sometime developer need to download PDF file and print that pdf document. Here I have shared a code snippet for download pdf then print that pdf using

@me_sohelrana: Download and then Print PDF File in AngularJS

Sometime developer need to download PDF file and print that pdf document. Here I have shared a code snippet for download pdf then print that pdf using angularJS.

$scope.printPdf = function (uuid){ $http({ url : ‘PDF_URL’, 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); var printwWindow = $window.open(pdfUrl); printwWindow.print(); }).error(function(data, status, headers, config) { alert(‘Sorry, something went wrong’) }); };

With this simple sample code snippet, you can easily download & print pdf by using angularJS.

Download and then Print PDF File in AngularJS