Embed the PDF in a webpage without using the built-in PDF viewer

前端 未结 5 445
孤城傲影
孤城傲影 2020-12-15 10:18

Currently I am using the standard way to embed an pdf to the browser, however, the built-in pdf viewer for my target browser is not working as expected. I would like to forc

相关标签:
5条回答
  • 2020-12-15 10:23

    You can use Google PDF viewer to embed pdf files on to your website. Use this link https://docs.google.com/viewer

    Example:

    <iframe src="http://docs.google.com/viewer?url={HTTP PATH OF THE PDF FILE}&embedded=true" width="600" height="780" style="border: none;"></iframe>
    
    0 讨论(0)
  • 2020-12-15 10:28

    You can use document-viewer or best-pdf-viewer

    The above uses javascript, html. Yes if you don't want to convert these in js or html then you can use Swftools. Here you can make your own skin, then read : SWFTools (pdf2swf) to properly work with Flex

    Showing pdf in Iframe may be another option.

    You problem may match with Show pdf file into browser without Adobe Reader

    0 讨论(0)
  • 2020-12-15 10:41

    I did this a while ago. Using JQuery was a great way to get round this :)

    pdf.js:

    https://github.com/mozilla/pdf.js

    Hope this helps!

    0 讨论(0)
  • 2020-12-15 10:45

    Trick Chrome and Firefox (and maybe other browsers) into displaying the PDFs using the Adobe Reader plugin (for full PDF Open Parameters support among other benefits) by using one of the following 'Adobe PDF in XML Format' types in your embed code:

    application/vnd.adobe.pdfxml
    application/vnd.adobe.x-mars
    

    This works fine as of my answer today and I'm hopeful it will continue to work fine. I'm using it currently with standard PDF files as a workaround for embedding PDF files in the browser that need to use the Adobe PDF plugin rather than the browser's built-in PDF rendering. Even though my PDF files are standard (non-XML) files, they appear to load just fine with this new application type parameter.

    <OBJECT data="YourFile.pdf" TYPE="application/vnd.adobe.pdfxml" TITLE="SamplePdf" 
    WIDTH=200 HEIGHT=100>
        <a href="YourFile.pdf">shree</a> 
    </object>
    
    0 讨论(0)
  • 2020-12-15 10:49

    Check out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.

    In your HTML, you could set up a div to display the PDFs:

    <div id="pdfRenderer"></div>
    

    Then, you can have Javascript code to embed a PDF in that div:

    var pdf = new PDFObject({
      url: "https://sample.pdf",
      id: "pdfRendered",
      pdfOpenParams: {
        view: "FitH"
      }
    }).embed("pdfRenderer");
    

    Cheers

    0 讨论(0)
提交回复
热议问题