0

I am using iTextSharp to create on PDF document, later i want to add "Adding Enable for commenting Adobe Reader" using Acrobat, but i getting error as

You do not have permission to write to this file

Here my code used to create PDF file:

using (FileStream FS = new FileStream(dPDFFile_temp, FileMode.Create, FileAccess.Write, FileShare.None))
{
    using (Document Doc = new Document())
    {
        using (PdfCopy writer = new PdfCopy(Doc, FS))
        {
            Doc.Open();

            for (int i = 1; i <= R.NumberOfPages; i++)
            {
                writer.AddPage(writer.GetImportedPage(R, i));
            }
            Doc.Close();
        }
    }
}
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44

1 Answers1

1

You are asking something that is impossible: see http://support.itextpdf.com/node/24

Making a PDF reader-enabled requires a private key that is owned by Adobe. Any third party other than Adobe using that key, would be in violation with the law.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • 1
    Ya, its correct, i not asking about to add "Adding Enable for commenting Adobe Reader" using iTextSharp. i was created PDF file using iTextSharp, later i want to add "Adding Enable for commenting Adobe Reader" option using Acrobat only, but i am getting error as "You do not have permission to write to this file", so what is the reason for this error message? – Thirusanguraja Venkatesan Sep 20 '13 at 05:30
  • Are you sure you don't have the file open in another process. For instance: I had the same problem after a Windows 7 upgrade. As it turned out, Explorer **always** opened a preview window for PDFs and this locked the file. If that's not the problem, please share the document with us and tell us which version of Acrobat you're using (I have Acrobat 9 and XI; somebody else at the company has Acrobat X). – Bruno Lowagie Sep 20 '13 at 07:28
  • I am using Acrobat 7 and 9. in both version i am getting same problem. – Thirusanguraja Venkatesan Sep 20 '13 at 07:40
  • OK, I've created a PDF with iText and reader-enabled it with Acrobat 9: http://itextpdf.org/documents/hello_test.pdf I had no problem whatsoever with it. Share your PDF and I'll try doing the same with yours. Or, if you don't want to share it, use Preflight to check for syntax errors. You're concatenating existing PDFs, maybe one of those existing PDFs has syntax errors. – Bruno Lowagie Sep 20 '13 at 07:54
  • This is original file “demo.pdf” [https://www.dropbox.com/s/7s6fdh7y489gk8e/demo.pdf](https://www.dropbox.com/s/7s6fdh7y489gk8e/demo.pdf), I am removed one link from the original file and created new file “demo_temp.pdf” [https://www.dropbox.com/s/fll7f9tgr4rshqc/demo_temp.pdf](https://www.dropbox.com/s/fll7f9tgr4rshqc/demo_temp.pdf) , I am able to add “Comment Enable in” demo.pdf, but not in demo_temp.pdf. – Thirusanguraja Venkatesan Sep 20 '13 at 08:20
  • I want remained that if we create fresh PDF using iTextSharp will not create any problem. If we try to do any modification in existing PDF then it will create this problem. – Thirusanguraja Venkatesan Sep 20 '13 at 08:30
  • Yeah, I found the problem. You claim you removed the link, but you didn't. Instead you removed the `/Rect` from the annotation dictionary, thus creating a PDF with a syntax error. Kind of misleading not to mention that in your question. – Bruno Lowagie Sep 20 '13 at 08:37
  • Sorry for my lack knowledge, could you advice me how to remove the links from the PDF. – Thirusanguraja Venkatesan Sep 20 '13 at 09:33
  • Note that i want remove Links as well as that Annotation mark "\Rect" Box also from the PDF. – Thirusanguraja Venkatesan Sep 20 '13 at 09:49
  • Just i want to remove All Link Annotation with the URI as www.xyz.com. please give me suggestion. – Thirusanguraja Venkatesan Sep 20 '13 at 10:50
  • hi just now i do't have any idea to remove the Annotations from the PDF, any how now i just replaced the Link /Rect value into [0, 0, 0] and /URI value into empty just to hide the Link. If you got any idea share with me. – Thirusanguraja Venkatesan Sep 20 '13 at 11:48
  • Instead of using the comments as a way to post additional questions, please create a new question: "how do I remove link annotations from a PDF using iText" I can't (and won't) answer that question in a comment window, but I can in an answering window. – Bruno Lowagie Sep 20 '13 at 13:57
  • Question is below: http://stackoverflow.com/questions/18974031/how-do-i-remove-link-annotations-from-a-pdf-using-itext – Thirusanguraja Venkatesan Sep 24 '13 at 06:02