DCSIMG
Export to PDF open source framework - Wortzel's blog

Wortzel's blog

.Net (2.0, 3.0, 3.5), C#, Asp.net, Com+, GIS(ESRI Software), Management, Analysis & Design, Life, Trips, And more...
Export to PDF open source framework

On my last project I had a mission to find an appropriate framework for exporting some images and text to a Pdf file format.

The basic guidelines that lead me were:

-         This framework should be developed under the .Net framework.

-         It must be an open source code and not just black box.

-         The export to a Pdf process shouldn't affect the exported image quality.

-         The framework will be easily to use.

After searching over the net I found the solution => The ITextSharp framework answers all my requirements.

ITextSharp is a .Net open source libraries that allows you to generate a Pdf file in run time. I added a basic example for working with this framework:

public static void ExportToPdfFile(string )
{
   // step 1: creation of a document-object
   Document document = new Document();

   // step 2:
   // we create a writer that listens to the document
   // and directs a PDF-stream to a file
   PdfWriter.getInstance(document, new FileStream("MyPdfFile.pdf", FileMode.Create));

   // step 3: we open the document
   document.Open();

   Image jpeg = Image.getInstance(new Uri
("http://itextsharp.sourceforge.net/examples/myKids.jpg"));

   // step 4: we add the image to the document
   document.Add(jpeg);

   // step 5: we close the document
   document.Close();
}

Defiantly, it's a powerful framework that allows you to export almost everything to a Pdf file.

Published Wednesday, June 13, 2007 7:21 AM by Avi Wortzel

Comments

No Comments