2

Is there any angularJS directive to print local PDF file without opening print dialog box, And with the possibility of passing custom printer settings.

Lakshman
  • 47
  • 7

1 Answers1

1

Just use a iframe

<iframe src="{{src}}" frameborder="0"></iframe>

And pass the value of src from controller like below

$scope.link = 'Address of local pdf file'
$scope.src = $sce.trustAsResourceUrl(
    'https://docs.google.com/gview?url='+$scope.link+'&embedded=true'
);

This will print your pdf in the form of google docs

EDIT

You can embed the same link like this

<embed ng-src="{{src}}" style="width:200px;height:200px;"></embed>
Rakesh Chand
  • 3,105
  • 1
  • 20
  • 41
  • 1
    This looks like it would work for ***any*** visible HTML element, so long as it was included in an iframe, which could even be positioned off screen. Excellent! It might even get round my problem of how to print a grid which is not all visible in the browser, only the first X rows – just display ***briefly*** with 999,999,999 rows in an off-screen iframe, print then destroy. – Mawg says reinstate Monica Mar 10 '17 at 08:29
  • Any other way ?? I don't want to print in the form of google docs. – Lakshman Mar 10 '17 at 08:58
  • you can embed the link. edited answer, if you don't want to use neither of above then there are many angular libraries you can use like https://github.com/sayanee/angularjs-pdf – Rakesh Chand Mar 10 '17 at 09:42
  • Sorry my question is like how to print hard copy of a local PDF file using local printer without opening print dialog box.. – Lakshman Mar 11 '17 at 03:53