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.

2
  • 1
    Generate PDF with javascript Commented Mar 10, 2017 at 7:47
  • My question is nowhere related to generating a PDF. Commented Mar 10, 2017 at 9:10

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

4 Comments

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.
Any other way ?? I don't want to print in the form of google docs.
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
Sorry my question is like how to print hard copy of a local PDF file using local printer without opening print dialog box..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.