使用jQuery / AngularJs将Pdf文件加载到div中

时间:2022-08-18 09:49:20

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

如何使用jQuery / AngularJs将pdf文件加载到div中

ex:

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

or in angularJs

或者在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


2  

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

您可以在iframe中嵌入PDF。还有一些javascript库可以增加一些改进。

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 ...

我会考虑再次这样做的理由。我认为在新窗口中打开PDF会好得多...

#1


2  

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

您可以在iframe中嵌入PDF。还有一些javascript库可以增加一些改进。

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 ...

我会考虑再次这样做的理由。我认为在新窗口中打开PDF会好得多...