locked
itextsharp creating a corrupt / blank pdf file, i-9 file RRS feed

  • Question

  • User-1912745793 posted

    I have been using Itextsharp for prefilling the fillable pdfs in .aspx pages. But when I am trying to do the exact same thing with i-9 file (downloaded from dept of homeland security), its generating a blank (size 0) pdf which is corrupt and couldn't be opened.

    I am just copying the code snippet (I have all the necessary Itestsharp references in my solution) which is generating a corrupt pdf file (size 0).

    string pdfTemplate = @"c:\PDF\i-9.pdf";
      string newFile = @"c:\PDF\completed_i-9.pdf";
      PdfReader pdfReader = new PdfReader(pdfTemplate);
      PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(
                                                                   newFile, FileMode.Create));
      pdfStamper.Close();


    However, if I do the same thing with any other fillable pdfs e.g. w4 it works perfectly fine. Any idea guys, what is going wrong in here?

    Thanks


    Tuesday, December 14, 2010 6:51 PM

Answers

  • User-1912745793 posted

    Never mind guys... I see what the problem was... posting it here, in case any lands up searching for the same issue.  Even though this file i-9 gets opened without any password prompt (it actually has an open password which is empty, and thus opens it without asking for it), it has an owner password associated with it, which probably is governed by homeland of security.  Without this privilege, it is not possible to modify this file (you can check its security settings by pressing ctrl + d and checking the security tab) . You will see it has its content copy disabled for open user.

    Since it is a password secured file and the intention was not letting anyone to be able to modify it, I am not going to try to modify it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 15, 2010 4:57 PM

All replies

  • User-1912745793 posted

    Anyone?

    Wednesday, December 15, 2010 11:17 AM
  • User-1912745793 posted

    Never mind guys... I see what the problem was... posting it here, in case any lands up searching for the same issue.  Even though this file i-9 gets opened without any password prompt (it actually has an open password which is empty, and thus opens it without asking for it), it has an owner password associated with it, which probably is governed by homeland of security.  Without this privilege, it is not possible to modify this file (you can check its security settings by pressing ctrl + d and checking the security tab) . You will see it has its content copy disabled for open user.

    Since it is a password secured file and the intention was not letting anyone to be able to modify it, I am not going to try to modify it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 15, 2010 4:57 PM