Original address: http://www.cnblogs.com/Creator/archive/2010/03/13/1685020.html
C # Reference itext create PDF document
Refer to Itext to download components from here
Five steps to create a PDF in the following illustration
First step: Create an instance of a file object
Document mydocument= New Document (PageSize.A4.Rotate ());
Step Two: Create a writer listener file and write the desired stream to the file
Pdfwriter.getinstance (MyDocument, New FileStream ("Salman.pdf", FileMode.Create));
Step three: Open the file
Mydocument.open ();
Fourth step: Write some content to the file
Mydocument.add (New Paragraph ("First Pdf File made by Salman using IText");
Fifth step: Finally remember to close the file
Mydocument.close ();
Using System;
Using System.IO;
Using System.Diagnostics;
Using Itextsharp.text;
Using ITextSharp.text.pdf;
Publicclass Itextdemo
{
Publicstaticvoid Main ()
{
Console.WriteLine ("IText Demo");
Step 1:creation of a Document-object
Document MyDocument =new Document (PageSize.A4.Rotate ());
Try
{
Step 2:
Now create a writer, that listens-doucment and writes the document to desired Stream.
Pdfwriter.getinstance (MyDocument, New FileStream ("Salman.pdf", FileMode.Create));
Step 3:open the document now using
Mydocument.open ();
Step 4:now Add some contents to the document
Mydocument.add (New Paragraph ("First Pdf File made by Salman using IText");
}
catch (Documentexception de)
{
Console.Error.WriteLine (DE. Message);
}
catch (IOException IoE)
{
Console.Error.WriteLine (IoE. Message);
}
Step 5:remember to close the documnet
Mydocument.close ();
}
}
To view the original English, click here
. NET Quick Create PDF document by C #