Create PDF
In the following example, you create a simple PDF document. Creating PDF documents programmatically using DynamicPDF Core Suite is straightforward, and provides access to the document, pages in the document, and content (using page elements) on each page.
Watch the Video
How to Create a PDF
The following steps illustrate creating a PDF document using DynamicPDF Core Suite.
Steps for Creating a PDF Document
- Create a
Document
object. - Create a
Page
object and add it to the Document instance. - Set the
PageSize
asLetter
and thePageOrientation
asPortrait
. - Create a text string,
labelText
, create aLabel
object, and add the string to the label. - Add the Label instance to the page Instance.
- Call the Document object's
Draw
method to draw and save the PDF document.
Sample Code - C#
Document document = new Document();
Page page = new Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);
document.Pages.Add(page);
string labelText = "Hello World...\nFrom DynamicPDF Generator for .NET\nDynamicPDF.com";
Label label = new Label(labelText, 0, 0, 504, 100, Font.Helvetica, 18, TextAlign.Center);
page.Elements.Add(label);
document.Draw("Output.pdf");
Page Elements
The DynamicPDF Core Suite contains over 75 page elements to add rich content to your PDFs. DynamicPDF Core Suite includes elements for creating:
- Images,
- Text Objects (TextArea and Label),
- HTML,
- Barcodes (over 47 types),
- Form Fields,
- Charts,
- and many other elements.
For a complete listing, refer to the Page Elements.
GitHub Project
Clone or view the example project at GitHub. The examples on this page are in the Examples/CreatePDF.cs file.
Getting Started
NuGet Package
The DynamicPDF Core Suite package is available as a NuGet ceTe.DynamicPDF.CoreSuite.NET
package. The easiest way to install the package is through the Visual Studio Package Manager. You can also download the package directly from NuGet.
DynamicPDF Core Suite Information
More information on DynamicPDF Core Suite can be found on the website.
Other Platforms
DynamicPDF Core Suite is also available for Java and COM/ActiveX. Refer to the respective product pages for more details.
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX