Angular JS PDF generation - any creator modules?

As the title says, is there a PDF creator / generator for Angular?

I saw https://github.com/MrRio/jsPDF but can't find it for Angular. I want to make an html page for a pdf file to download.

+8
javascript angularjs pdf meanjs
source share
4 answers

You can wrap the JavaScript project you mentioned in a service that you invoke throughout the application. This is actually pretty standard practice, and it also isolates your code if you ever need to change the underlying implementation.

+6
source share

It looks like @Mike is close there. A few quick changes created a decent file and raised a print popup. A.

1 - indicate the area in which you want to print the identifier 'printArea'

2 - add $ window service

$scope.printIt = function(){ var table = document.getElementById('printArea').innerHTML; var myWindow = $window.open('', '', 'width=800, height=600'); myWindow.document.write(table); myWindow.print(); }; 
+5
source share

You can use window.print (), which prints the current HTML document. Use media queries to customize your stylesheet. You can create your document on the fly and print at any time.

 @media print { /* All your print styles go here */ #header, #footer, #nav { display: none !important; } } 

Some code from one of my projects only prints contents from a table:

  $scope.print = function () { console.log('modal print'); var table = document.querySelector('.CSSTableGenerator').innerHTML; var myWindow = window.open('', '', 'width=800, height=600'); myWindow.document.write(table); myWindow.print(); }; 
+1
source share

Here, this Angular directive terminates jsPDF :

https://github.com/sayanee/angularjs-pdf

+1
source share

All Articles