Juanjo Salvador Juanjo Salvador -3 years ago 171
AngularJS Question

Ionic print to PDF the current page

I have an Ionic app (AngularJS), and I need to print (as PDF) an app's view. Currently I'm using

but when I try to print the page, I get an error.

This is my code. Printer is available (using Android 4.4.2 and 5.1 on emulator), but always there is an error getting the page. And nothing works.

$scope.print = function() {
if($cordovaPrinter.isAvailable()) {
var page = location.href;
$cordovaPrinter.print(page, "Document");
} else {
alert("Printing is not available on device");

I need to print a table with rows like this:

<tr ng-repeat="data in tableData">
<td>{{ data.id }}</td>
<td>{{ data.field_one}}</td>
<td>{{ data.field_two }}</td>

And I'm afraid of my plugin doesn't support the curly brackets syntax...

Answer Source

Finally I found a solution creating a PDF (I followed Ashteya Biharisingh's tutorial) and wrinting it to a file using $cordovaFile.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download