Is there any angularJS directive to print local PDF file without opening print dialog box, And with the possibility of passing custom printer settings.
1 Answer
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>
4 Comments
Mawg
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.
Lakshman
Any other way ?? I don't want to print in the form of google docs.
Rakesh Chand
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 github.com/sayanee/angularjs-pdf
Lakshman
Sorry my question is like how to print hard copy of a local PDF file using local printer without opening print dialog box..