1

How to load a pdf file into a div using jQuery/AngularJs

ex:

 $.get('/helper/test.pdf', function(data){
              $("#div1").html(data); // like to render pdf in this div
           });

or in angularJs

 $http({ method: 'GET', url: '/helper/test.pdf'}).
           success(function (data) {
               $scope.model.pdfData = data;
           }).
           error(function (data) {
               //alert(data);
           });

Please help me to do this

1
  • 1
    you can try using pdf.js by Mozilla using their viewer Commented Feb 22, 2014 at 12:41

1 Answer 1

2

You can embed your PDF in iframe. There are also javascript libraries which adds some improvements.

There is SO topic about this: How to open a PDF file in an <iframe>?

I would consider reasons to do this again. I think it is much better to open a PDF in new window ...

Sign up to request clarification or add additional context in comments.

Comments

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.