Search code examples
phppdfiframeembed

How to embed a pdf in HTML and print that with cmd+p / ctrl+p


I am trying to include a pdf file in my HTML page and allow users to print that by using cmd+p or ctrl+p.

Here is my code -

<html>
    <body>
          <p> I want to print this page with pdf  </p>
          <iframe src="/my.pdf" width="800px" height="2100px" />
    </body>
<html>

When I visit my page I am able to see the pdf file but when I try to print it shows me a blank page for pdf.

I am building this application with PHP. I have tried the embed and object tag also but had no luck with this.

Please help me to fix this.


Solution

  • Such functionality is not possible as explained here: Print Pdf from javascript embed tag

    The only real thing you can do is try to convert the PDF to images and use the "@media print" tag to style the printing page appropiately.