Pankaj Agrawal
Pankaj Agrawal

Reputation: 1659

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.

Upvotes: 0

Views: 1431

Answers (2)

bonnie
bonnie

Reputation: 1

It's a different matter Record it for others.

If there are a lot of blank pages, the class you want to print out:

@media print{
.paper {
display:inline-block
}
}

Apply above CSS. My problem solve by this trick.

Upvotes: 0

Enigmatic
Enigmatic

Reputation: 388

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.

Upvotes: 1

Related Questions