Click here to Skip to main content
15,867,321 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on PDF's to display on web browser on button click. When i display it on page that PDF toolbar should hide/disabled and I can do the operation with buttons(Page Up & Page Down) out side of this page. I am using MVC 4 with Razor(CSHTML).

Please help me in how to do it.
Posted

1 solution

PDF is not a part of W3 standards. Even though wide range of browsers informally support it (usually with separate pluggable PDF viewers), you should never rely in the fact the client system has such support.

You can switch to pure HTML. If PDFs are essential for the business (which would be the pretty usual case), you can do one of the two:
  • Provide PDF content (using the content type "application/pdf" as needed, please see http://www.iana.org/assignments/media-types/media-types.xhtml#application[^]).

    The rest of it will depends on the client side. If in-browser viewer of PDF is available to the client's browser, the document will be shown, otherwise, the user will get an option: open the document using default PDF viewer installed on the client system or download the file. If no default viewer is installed, the user will be left with the option to download it. After downloading, the use may decide to view the document somehow; this is left to the user.

    Personally, I think this is a very best option, not only because it is the simplest, also, it is the least intrusive and convenient for most reasonable users.
  • Alternatively, you could somehow map PDF onto HTML (which have no one-to-one correspondence, because rendering concepts are radically different) and convert PDF to some HTML representation on the fly:
    http://bit.ly/JUPgLO[^].


Good luck,
—SA
 
Share this answer
 
Comments
Member 10711974 9-May-14 7:49am    
Thanks for reply... I am doing it with iFrame and loading the pdf from other url like http://locahost:<>/test.pdf and its working but how to handle the pages of pdf to move up/down from outside buttons?
Sergey Alexandrovich Kryukov 9-May-14 10:09am    
Any motivation? Why iFrame? Why outside buttons? You are asking from the standpoint of behavior not supported by any standards. PDF viewer have they ways of scrolling and all that. The PDF plug-ins have their ways to talk to the browsers, and the browser plug-in architectures (if they are good enough) have all the provisions to scroll the documents viewed by plug-ins. Why trying to break all that?
—SA
Member 10711974 16-May-14 6:08am    
Users will be using my app on tabs and other touch screens. So, when they are viewing from tab/touch screens the scroll bar of pdf is not working. Hence, I thought of implementing it with buttons outside of it.. Where Iframe loads only the pdf but we can't control the pages of pdf inside frame. So, you are suggesting me to use PDF viewer plug-in? Is it have my requirements?
Sergey Alexandrovich Kryukov 16-May-14 10:27am    
No, "to use PDF viewer plug-in" means just not worrying about PDFs. The user's system have the support for them. If not, the fallback is saving. You should trust client's systems.
The alternative is switching to HTML.
—SA
Member 10711974 16-May-14 7:57am    
and even I am disabling toolbar of pdf while loading in Ifram to prevent from clicking Save/Print options. Please suggest what way I can achieve my requirement, is that I should only display pdf file part of the webpage and toolbar should be disabled and I should have the link buttons outside of frame for Page up/down. Thanks!

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