- #Itextsharp pdfstamper pdfwriter add element pdf#
- #Itextsharp pdfstamper pdfwriter add element full#
- #Itextsharp pdfstamper pdfwriter add element download#
Setting paragraph's text alignment using class Lets implement: Paragraph para = new Paragraph( " Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World") So, after creating the Paragraph object and setting Alignment property, we can pass this object to 's constructor during Document ceration. The following are Alignment types provides iTextSharp:Īs we already see the 's constructor takes 's object during Document creation. These Alignments can be access through class. iTextSharp Library provides various types of Alignments. Lets implement: Document doc = new Document(PageSize.A4, 36, 72, 108, 180) Īlignment is one of the property of 's object. So, we need to do set the following points for the Left, Right, Top, Bottom Margins respectively as we already know that iTextSharp library only understand points where 72 points = 1 inch. Margins can be set during Document object creation like Page Size Rec2.BackgroundColor = new CMYKColor( 25, 90, 25, 0) CMYKColor constructor takes only CMYK values in different forms: BaseColor constructor takes in-built object Or you can pass RGB values to the constructor in different forms:
There are a few ways to set background color:
#Itextsharp pdfstamper pdfwriter add element pdf#
either 'rec', or 'rec2' or 'rec3' to the 's constructor during object creation like below: Document doc = new Document(rec) Setting Background Color of PDF Document: Now, just pass this object (any one) i.e. Rectangle rec3 = new Rectangle(PageSize.A4.Rotate())
#Itextsharp pdfstamper pdfwriter add element full#
Read the full Documentation of Page Size: The following are the Supported in-built Page Size.
Rectangle rec2 = new Rectangle(PageSize.A4)
Rectangle rec = new Rectangle( 144, 720) Suppose we want to create a PDF File of width = 2 inch & height = 10 inch, then we need 144pt for 2 inch & 72pt for 10 inch. NOTE: In iTextSharp library, unit is 'point'. There are a few way to define Page Size:Ĭreating Page Size by Pixels or Inch. Step 5: Adding a Paragraph by creating a object:ĭoc.Add( new Paragraph( " Hello World")) Ĭreating a Page of specified size, we must have to create a object and Passing the size as argument to its constructor.PdfWriter writer = PdfWriter.GetInstance(doc, fs) It helps to write the Document to the Specified FileStream: Step 1: Create a System.IO.FileStream object:įileStream fs = new FileStream( " Chapter1_Example1.pdf", FileMode.Create, FileAccess.Write, FileShare.None).Quick Start Creating PDF Document in 6 Steps: The necessary namespace that you have to add into your C# file to do what are in this Article are::.Add the following library into your project by adding reference to that library DLL.
#Itextsharp pdfstamper pdfwriter add element download#
Or you can download the library DLL from the above link or from the SourceForge.