Archive for the 'iTextSharp(iText#)' Category

An Bug of iText and iTextSharp

Somebody sent me a encrypted PDF to ask me help decrypt, I tried pdfcrypt, it got error. and when used pdfcrack, got the following warning messages,

WARNING: O-String != 32 Bytes: 33
WARNING: U-String != 32 Bytes: 33

After studied the source code of iTextSharp, I noticed it is a bug of iTextSharp in SetupGlobalEncryptionKey method of the PdfEncryption class,
misused the this.ownerKey and ownerKey and we can only find this bug when the PDF has strange length of ownerkey/userkey, for example 33, not 32.

this.documentID = documentID;
//this.ownerKey = ownerKey;
Array.Copy(ownerKey, 0, this.ownerKey, 0, 32);
this.permissions = permissions;
// use variable keylength
mkey = new byte[keyLength / 8];

//fixed by ujihara in order to follow PDF refrence
md5.Reset();
md5.BlockUpdate(userPad, 0, userPad.Length);
//md5.BlockUpdate(ownerKey, 0, ownerKey.Length);
md5.BlockUpdate(this.ownerKey, 0, this.ownerKey.Length);

Then I review iText 5.1.1 and find it has the same bug:

this.documentID = documentID;
//this.ownerKey = ownerKey;
System.arraycopy(ownerKey, 0, this.ownerKey, 0, 32);
this.permissions = permissions;
// use variable keylength
mkey = new byte[keyLength / 8];

// fixed by ujihara in order to follow PDF reference
md5.reset();
md5.update(userPad);
//md5.update(ownerKey);
md5.update(this.ownerKey);

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

Converting Adobe Designer Static forms to Acrobat PDF Forms

In Ted Padova’s post, he said,

Adobe Designer 8 supports two different types of forms: Static forms and Dynamic forms. If a form is created as a static form you can easily convert the form in Acrobat 8 to a PDF form.

and he give the steps on how to convert Adobe Designer forms to Acrobat PDF Forms.

This let me thought that I have also done this kind job before, but I did not rely on Adobe Acrobat, just rely iTextSharp, I have used it in my demo software FormServer, and it also have a online demo, Fill and Save PDF Form online, in fact they are the clone of commercial software.
Here is some features about FormServer,

  • support automatically convert static PDF forms created by Adobe Designer to Acrobat Form.
  • support save data to PDF Forms without Adobe Acrobat, only Adobe reader is enough.
  • support save data to FDF

And a HK company found my FormServer, and asked for the source code of “Converting static PDF forms created by Adobe Designer to Acrobat Form”, finally I sold they on US$400.

PS.
With the examples of Bruno Lowagie,Using iText to Fill PDF Forms Created by Adobe Designer, iText can both support Dynamic Forms and Static Forms created by Adobe Designer now.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

Digital Signature PDF Documents With Free Software

A digital signature is like a paper-based signature – each giving you a method for adding a unique identifier to a document. Both provide you with an easy way to show a person signed a particular document at a particular time, but a digital signature goes further as it can ensure that the document content has not been tampered with after it was signed. In addition, the document version history can let recipients see when a document was signed and see when any changes were made to it. This revision history is encrypted and stored inside the PDF and can be viewed at anytime via the Signatures pane.

To digitally sign a PDF document, you must have a digital ID, and to verify other people’s signatures, you must first share your digital IDs and add each other to your Trusted Contacts list.

Most Digital Signature software are not free, but I will introduce you some free software developed in JAVA and DOTNET with the power of iText and iTextSharp.

Want to develop your own? please visit How to sign a PDF using iText and iTextSharp.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride