0

My code is as under to open a pdf on page , but I want to remove save and print toolbar from my PDF

    protected void Button1_Click(object sender, EventArgs e)
    {
        string FilePath = Server.MapPath("javascript1-sample.pdf");
        WebClient User = new WebClient();
        Byte[] FileBuffer = User.DownloadData(FilePath);
        if (FileBuffer != null)
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-length", FileBuffer.Length.ToString());
            Response.BinaryWrite(FileBuffer);
        }

    }
  • You'd probably have to grab some sort of library that can create a pdf object that allows you to change security settings for the PDF. Right now it just looks like you're just grabbing a byte array that happens to output as a pdf. – Camilo May 26 '15 at 18:56
  • I dont want to use any 3rd party library – Mohammed Asadullah May 26 '15 at 19:24
  • Then you're probably out of luck. From what I've seen, any code to manipulate a PDF is done through 3rd party libraries. – Camilo May 26 '15 at 19:35
  • Here is another question where itext is used to create an pdf where they have controlled permissions. http://stackoverflow.com/questions/1936189/itext-disable-printing-copying-saving – Teis Lindemark May 27 '15 at 11:26
  • I am using PDF.Js and it is the coolest free PDF Viewer I have ever seen – Mohammed Asadullah Jun 07 '15 at 20:24

1 Answers1

0

When you create the PDF, you can disable the save and print permissions. So, even if the toolbar is displayed, the options won't be enabled. You can modify the permissions on an existing PDF as well. Of course, you need some PDF software or library to modify the permissions.

gn1
  • 526
  • 2
  • 5