Click here to Skip to main content
14,973,021 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have specific requirement that when PDF file uploaded by user is shown, Save as button and print button should be disable for specific user based on their rights.

If user don't have sufficient rights then (s)he should not be able to save or print PDF.

Thanks in advance!
Dave Parth
Posted
Comments
Philippe Mori 20-Dec-11 18:50pm
   
It is not possible to do that as you don'have any control on that.

And since it is easy to grab the screen, then if the user can see it, he can save an image of it.

Not doable if using adobe.

Using another PDF viewer may allow it, but there is no surefire way, one can always save an image.
And since they are allowed to see the document, why should they not print it out?

Seems like a pointless requirement.
   
Comments
Dave Paras 20-Dec-11 5:44am
   
Hi dalak,
Thanks for your time and suggestion.
But it is required to do.
If you have any example using third party tools then please provide it.
Thanks Again.
I was also working on the same functionality but was only able to "ENABLE" print and securing PDF file with password.

Here is the code, it is saving the file in desktop. you can change the path as your requirement.

C#
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

protected void Page_Load(object sender, EventArgs e)
    {
        
        string WorkingFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        string InputFile = Path.Combine(WorkingFolder, "StickerSheet_New.pdf");
        string OutputFile = Path.Combine(WorkingFolder, "2.pdf");


        using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
            {
               
                PdfReader reader = new PdfReader(input);
                //PdfEncryptor.Encrypt(reader, output, true, "23!54", "23!54", PdfWriter.ALLOW_SCREENREADERS);               
                System.Text.UTF8Encoding Encoding = new System.Text.UTF8Encoding();

                PdfStamper stamper = new PdfStamper(reader, output);
                stamper.SetEncryption(Encoding.GetBytes("23!54"), null, PdfWriter.AllowScreenReaders, PdfWriter.STRENGTH40BITS );
                //output.ViewerPreferences.HideToolbar = true;
                //PdfReader pReader = new PdfReader();
                //PdfEncryptor.Encrypt(reader, new FileStream("1.pdf", FileMode.Open), PdfWriter.STRENGTH128BITS, "23!54", null, PdfWriter.AllowScreenReaders);
                stamper.Close();
                reader.Close();
                Response.Write("PDF created");
            }
        }
    }

  }
}


Still searching for enable saveas button in pdf file.
   
Comments
Dave Paras 17-Apr-12 3:10am
   
Thanks atul for response with code.
Now I'm out of that functionality :)
Atul Dhimaan 17-Apr-12 23:42pm
   
Welcome Dave... Hope you like the solution. It is easy to use.
Gurupatham 21-Apr-15 8:26am
   
How to disable pdf file save as button using iTextsharp (PdfStamper)? or any other solutions...?
Gurupatham 27-Apr-15 0:52am
   
Hi Atul Dhiman,

Did You find out the solution for disable save as button in PDF? If you find out the option please share with me (above you posted code very very useful for me)
Atul Dhimaan 6-Oct-15 3:42am
   
Hi Gurupatham, I dont know if your problem is resolved or not, but a solution that was fine to my situation, opening in a PDF Viewer.

I blocked the copy and print option as you probably know how, and then blocked the options Hide Menu Bar and Hide tool bars.

from File - Properties - Initial View. So, the save option is omitted.

For me these options were disabled, if you face the same problem, this can help you: http://forums.adobe.com/message/4013698.

My users don´t have the knowledge to unblock the bars, so for me was enough.
osaid 19-Apr-16 4:30am
   
Good, It worked
Member 13245006 19-Nov-19 6:17am
   
need to disable download and Print option from iframe PDF viewer
Hi Gurupatham, I dont know if your problem is resolved or not, but a solution that was fine to my situation, opening in a PDF Viewer.

I blocked the copy and print option as you probably know how, and then blocked the options Hide Menu Bar and Hide tool bars.

from File - Properties - Initial View. So, the save option is omitted.

For me these options were disabled, if you face the same problem, this can help you: http://forums.adobe.com/message/4013698.

My users don´t have the knowledge to unblock the bars, so for me was enough.
   

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