Click here to Skip to main content
14,450,268 members
Rate this:
Please Sign up or sign in to vote.
I am displaying the PDF in Browser using iframe but i want to disable the PDF viewer print method and need to print PDF file using button

thanks for advance

What I have tried:

<script language="javascript" type="text/javascript">
function print() {
var objFra = document.getElementById("ifrRight6");

<iframe id="ifrRight6" runat="server" enableviewstate="false" scrolling="auto" style="width: 100%;
-ms-zoom: 0.75; height: 685px;"></iframe>

in .CS
ifrRight6.Attributes["src"] = @"../PDF_Files/" + filename;
Updated 6-Jul-19 6:35am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can't. If you think about it, it's pretty obvious why.

Until fairly recently, browsers didn't know how to render a PDF file on-screen. The browsers used the MIME type of the content to determine that it was a PDF file and looked up any registered "handler" for that type to decode and display the content. In your case, that's whatever you're installed, like Adobe Reader.

Now, just because your printing, this requirement does NOT change. The browser STILL doesn't know how to interpret and render the content on-screen. Printing is just the exact same process, but on a printed page. The content is rendered to a virtual "screen" in a printer driver.
MadMyche 6-Jul-19 11:40am
And the ability to control and end-user's client program is a security risk

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100