Archive for August, 2007

Digital Signature and Timestamp to PDF Documents with iTextSharp

Today, I just finished a bid(project) from RAC, that is “Digital Signature and Timestamp to pdf document with iTextSharp”.
the requirement is:

PDF Sign and TimeStamp

Provide a fully functional desktop application and source code that can:
Sign a PDF file from user certificate (.pfx)
Add timestamp (RFC 3161) from designated TSA
Save signed pdf in designated file
File can be verified with Adobe Acrobat Reader
Support for multiple signatures

Written in C# using open source libraries Itextsharp and Bouncycastle

App similar to http://www.codeproject.com/useritems/Esignature.asp
but with timestamp capability

Similar JAVA apps available as open source but prefer native C# app.

screenshot.jpg
reference:

      http://security.polito.it/ts/

      http://www.codeproject.com/useritems/Esignature.asp

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

the Flying Saucer 100% Java XHTML+CSS renderer

The Flying Saucer Project, An XML/XHTML/CSS 2.1 Renderer (100% in java)

There are two great articles about using Flying Saucer for practical purposes:

Flying Saucer Features

Supported Features in CSS 2.1

Flying Saucer supports all of CSS 2.1 with a few exceptions. Consult the issue tracker for more information on what is not supported (in particular, the issues with a summary of “Support …”) or ask on the mailing list. If you do encounter a compliance bug or other unexpected behavior, please open a bug or post to the mailing list.

Features:

  • 100% Java XML+CSS layout engine with Java2D (Swing) and native PDF output. SWT coming soon.
  • Strong support for the CSS 2.1 specification including extensions to better support paged media.
  • Good performance.
  • Support for XHTML including forms.
  • Arbitrary elements may be replaced with custom content.
  • Limited support for dynamic effects (for example, the :hover pseudo-class and links)
  • Some support for PDF specific features (for example, bookmarks and internal links). More coming soon.

Limitations:

  • Resource loading is single threaded and occurs inline with layout.
  • Support for XHTML is weaker than XML+CSS (for example, not all XHTML presentational attributes are supported nor are X/HTML features like the <object> element).
  • No support for legacy HTML (although there are several open source Java HTML cleaners of varying quality available).
  • Swing printing is supported, but quality is lacking. Ask on the mailing list for details.
  • No support for incremental layout (applies to screen media only).
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

iText and iTextSharp support PDF/A-1 now

From iTextSharp mail list, I got a great news, iText and iTextSharp support PDF/A-1 now.

I’ve added support for PDF/A-1 and is available in the iText SVN and the iTextSharp CVS. An example:

example for java:
Document doc = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("C:\\hello_A1-b.pdf"));
writer.setPDFXConformance(PdfWriter.PDFA1B);
doc.open();
PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
outi.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
outi.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
outi.put(PdfName.S, PdfName.GTS_PDFA1);
ICC_Profile icc = ICC_Profile.getInstance(new FileInputStream("c:\\srgb.profile"));
PdfICCBased ib = new PdfICCBased(icc);
ib.remove(PdfName.ALTERNATE);
outi.put(PdfName.DESTOUTPUTPROFILE, writer.addToBody(ib).getIndirectReference());
writer.getExtraCatalog().put(PdfName.OUTPUTINTENTS, new PdfArray(outi));

BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf", BaseFont.WINANSI, true);
Font f = new Font(bf, 12);
doc.add(new Paragraph("hello", f));
writer.createXmpMetadata();
doc.close();

And for C#:

Document doc = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("C:\\hello_A1-b_cs.pdf", FileMode.Create));
writer.PDFXConformance = PdfWriter.PDFA1B;
doc.Open();
PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
outi.Put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
outi.Put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
outi.Put(PdfName.S, PdfName.GTS_PDFA1);
ICC_Profile icc = ICC_Profile.GetInstance("c:\\srgb.profile");
PdfICCBased ib = new PdfICCBased(icc);
ib.Remove(PdfName.ALTERNATE);
outi.Put(PdfName.DESTOUTPUTPROFILE, writer.AddToBody(ib).IndirectReference);
writer.ExtraCatalog.Put(PdfName.OUTPUTINTENTS, new PdfArray(outi));

BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\arial.ttf", BaseFont.WINANSI, true);
Font f = new Font(bf, 12);
doc.Add(new Paragraph("hello", f));
writer.CreateXmpMetadata();
doc.Close();

related files:
srgb.profile (4K) Download Attachment
hello_A1-b.pdf (23K) Download Attachment

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