Getting Started |
To start using Select.Pdf Library, follow the instructions from the Installation section to setup a project and add a reference to Select.Pdf.dll.
This section will show how to create a simple 'Hello World!' application with Select.Pdf.
The first thing to do when using Select.Pdf library is to create the pdf document that is an instance of PdfDocument class.
Once the document is created, a first page is need in the pdf document. To do that, the method AddPage of the PdfDocument class can be used. A page in a pdf document is an instance of the PdfPage class.
To add a text to a pdf document, a font is needed. A font in a pdf document is an instance of the PdfFont class.
To add a text to a pdf document, the PdfTextElement class can be used. After the PdfTextElement object is created, it must be added to the appropriate PdfPage object.
Once the content is created, you can save the document. The document can be saved to a stream or file on disk.
The full code of the 'Hello World!' application looks like this:
// create a new pdf document PdfDocument doc = new PdfDocument(); // add a new page to the document PdfPage page = doc.AddPage(); // create a new pdf font PdfFont font = doc.AddFont(PdfStandardFont.Helvetica); font.Size = 20; // create a new text element and add it to the page PdfTextElement text = new PdfTextElement(50, 50, "Hello world!", font); page.Add(text); // save pdf document doc.Save(file); // close pdf document doc.Close();