Is there any angularJS directive to print local PDF file without opening print dialog box, And with the possibility of passing custom printer settings.
Asked
Active
Viewed 957 times
2
-
1[Generate PDF with javascript](http://stackoverflow.com/questions/742271/generating-pdf-files-with-javascript) – Gangadhar Jannu Mar 10 '17 at 07:47
-
My question is nowhere related to generating a PDF. – Lakshman Mar 10 '17 at 09:10
1 Answers
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
-
1This 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
-
-
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