How to disable download option of pdf file in c# ? - c#

How to disable the pdf Toolbar because I don't want to give the download option to the pdf viewers.
I have used Iframe for showing Pdf File please find the following code
<iframe ID="iFrame2" runat="server" align="bottom" frameborder="2" name="iframe1" height="500" width="600" src="~/pdffiles/example.pdf"></iframe>
Please help me to disable the download option using c#.
Thanks

You cant. It is a browser feature which means you have no control over it.
You can use third party tools like Google Document Viewer or change the format of your document to an image.
Google Document Viewer

If you want to avoid that an end user saves a PDF document, you are asking something that is impossible. The only way to avoid that an end user doesn't have a copy of the PDF is by not sending him the PDF. A PDF can't be opened in Adobe Reader without having the actual bytes on the disk. Even if you would disable saving (for instance in the context of a web application), you'd always find the PDF somewhere in the temp files and people would be able to copy that file as many times as they want.
Trying to hide the toolbar (a viewer preference) doesn't make sense. Whether or not this viewer preference will be respected entirely depends on the PDF viewer. For instance: in Adobe Reader X and later, you have a special widget (HUD or Heads Up Display) that appears when you hover over the document. This widget allows users to save the document.
Let me quote Adobe:
the "Heads Up Display" (HUD) is not customizable. There are no APIs to
HUD. You can’t use JavaScript to enter Read Mode, exit Read Mode or
detect that the document is in Read Mode. Though it might seem like
it, this wasn’t an oversight. There are some very sound engineering
reasons why this is the case but I won’t go into those here.
Even with Adobe Reader 9, hiding the toolbar isn't sufficient: if the user chooses the appropriate menu item or hits the appropriate "hot key", the toolbar would appear and they could happily click the Save button. In addition, they could have right-clicked and chosen "Save" as well.
In short, you're asking the wrong question (and that probably explains the downvotes given by several people).

Related

How to convert PDF files to swf or HTML for viewing in C# MVC 4.5

I have hundreds of PDF files that i need to present to users. When presenting these files through my MVC web app i don't want the users to have the ability to download the files, e.g.. i don't want the Acrobat reader controls for print/save showing up. Reading this stackoverflow post it seems that it's not possible to disable those controls.
I know users can still take screen shots and print out the page, but that's not an issue in my case.
What is the best way to go about this. I've reasearched using SWFTOOLS which looks like it may be a good solution, but i dont want to save the swf files to my filesystem. The optimal solution is PDF.js, but another problem i have is users will be accessing the files through IE8 - so PDF.js is out of the question. Unless there is another similar library that will convert the files to HTML 4.
Basically I just need to display the PDF files, on the fly would be best, in a different format than PDF
Any suggestions?
I had a similar project a while back, where sensitive pdfs were needed to be displayed to specific users but they weren't allowed to download/print/save it.
Since it was a web app I ended up using pdf.js. It is Mozilla's PDF renderer for firefox. It renders the pdf on to a canvas and by default has all the bells and whistles. If you have firefox, open a pdf file to see it in action.
It was tough to get it running at first but I ended up using a demo I found online as the base of the project. After removing each functionality that was forbidden the finished product did exactly what was required. You will need to add a print css file to block printing or find a better solution. I ended up using the css approach since print preview by passed my javascript check for the print action. Also ensure you block ctrl + s which allows the user to save the pdf.
Another aspect to note is that it works better on later versions of IE and struggles on older versions as the file size increases. Firefox and chrome are not a problem and I believe its the same for opera although I haven't tested that.
I would convert it to an image file, you can find tools or write script to do it, I personally would do it by displaying them in browser first and then use browser plug-ins to take screenshot of the entire webpage.
(you can automate this)
then just display then converted pdfs
**this is probably not the best solution :( **

Best way to display pdf document in asp.net application

I'm looking for the best way to display pdf document on a website. Surely I need to convert it to jpeg or gif for the browser to handle it. I read few posts but most refer to GhostScript and its pdf2image. But that solution calls for starting a process that would save a copy of pdf doc to the file system and then would have to be loaded back into memory for displaying. Frankly I find it a bit clumsy. For those of you who have done it, what library you used and if you could attach a link to some examples, I'd greatly appreciate it.
I'm developick a web application that helps manage manufacturing process and is accessed fron android tablets. Company has a stockpile of documentation in pdf files that is to be delivered to production managers. I'd love the solution to be akin Crystal Report Viewer contron but I I understand that I have to stick to pdf to image conversion. Please give me some advise here.
My advice is don't over think this.
You can simply add a link to the PDF file, which will open on a new tab.
You can take a look at http://mozilla.github.io/pdf.js/ which will allow you to render a PDF on the client side.
Or if you decide to go with a Ghostscript, you can take a look at http://ghostscriptnet.codeplex.com
By all accounts the PDF Focus .NET library seems to be the best solution. A wrd of advice is to add a cleanup method to the page unload to delete all temporary files that were used to feed source into image controls when displaying pictures on a website.

pdf docs in silverlight

I have a requirement. I have to enable users to attach documents and that will get saved in the db in binary format.
Now the challenge is, I have to display the document list in the silverlight application and when user clicks on any of the link it should not ask for downloading the document instead it should open the document in the next tab. (the document could be pdf, png, excel, doc).
I have gone through multiple threads but all those thread ends on either third party tool or OOB. I cannot have OOB enabled.
I just want to check is there any way we can achieve this using silverlights inbuilt functions.
I think a combination of #Blam's comment of sending the proper mime type coupled with a Silverlight HyperlinkButton with the Target set for the new window would be your ticket. The XAML would look like this :
<HyperlinkButton Content="Name of PDF" Target="PDFWindow" NavigateUri="/DownloadPDF.aspx?id=BINDING OF UNIQUE ID" />
You'd add a page to your Silverlight project called DownloadPDF and it would take in one argument in the request variables; the unique ID of the PDF to grab from the database. DownloadPDF would change the mime type to "application/pdf" and then write the bytes from the SQL server to the response stream.

How to merge different document types and show as stack in .NET application

Suppose in .NET (don't care what language) I want to show a user a PDF, Word and Excel file together. I am trying to replicate a document process where a user might have a PDF file and he would like to attach a WORD file and an Excel file let's say to make a stack of documents (that I would save in some directory). Then he would like to click on a button and see a stack of these documents in 1 application of some sort.
How can I display the stack of documents WITHOUT first opening WORD, then openinig EXCEL and then openining ADOBE ACROBAT - this would be really annoying for the user. I would like one unified application or some idea to mimic one in .NET that can just show all 3 documents as if they were printed one after the other on paper. (I hope I am explaining this clearly)
The only thing I can think of to do this would be to leverage some sort of PDF conversion process to create one PDF file containing all three of these documents in "printed" (page-by-page) form, and then show that. The one application I can think of that could show all of these files is a web browser with appropriate Office and Acrobat viewer plugins, and you might find it difficult to leverage that, as browser preference and other user OS settings can cause various strategies for application launching to fail.
I would convert the documents in PDF and develop a pdf viewer inside your application.
I would use a ready made library for that, don't reinvent the wheel.
For example: http://www.quickpdflibrary.com/products/quickpdf/index.php

generate a pdf file an asp.net(ajax) c#

I have a web page in which user has to enter many details.
I want to fetch the records that are being entered by the user and generate a pdf file, and also preview it in a browser.
I also want to save the pdf into the database.
Can anyone help me to understand how this process should start?? I mean how should I proceed?
I am using Visual Studio 2008 and mysql. I have adobe reader installed on my system. What else do I need?
Can I get the tutorials or code samples which will help me.
thank you
Adobe Reader is just what it says, a Reader application, and will not help with generating a PDF. I recommend you to have a look at iTextSharp
You'll need a third party library for the pdf generation, such as Report.net or ITextSharp.
The problem I see with browser preview, is that I don't know of a good way of doing it. If you just want to show them the data that goes in to the PDF, then just displaying that on a web page is easy enough. The problem is previewing the actual PDF. That will require the user to have some sort of PDF reader installed, and it will also require that their browser opens the PDF automatically and doesn't try to save it instead. It also has the problem of how the user will "get back" to your website once they're done with the previewing.

Categories

Resources