Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 asp.net button

thanks for advance

What I have tried:

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

<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;
Posted
Updated 6-Jul-19 5:35am

1 solution

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.
 
Share this answer
 
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900