Examples

Adding Templates to PDFs

Adding a template to add page elements to all pages at once in a PDF document or section is a breeze when using DynamicPDF Core Suite for .NET. The following C# examples illustrate.

How to Add Template to PDF

The following steps and C# sample code illustrate adding a Template to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding Template to a PDF Document


  1. Create a Document object.
  2. Create a Template object.
  3. Add the required page elements to the Template instance.
  4. Assign the Template instance to the Document instance.
  5. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Template template = new Template();
template.Elements.Add(new Label("Header", 0, 0, 200, 12));
template.Elements.Add(new Image("DPDFLogo.png"), 100, 0));
document.Template = template;
document.Draw("Output.pdf");       


Template used to create a PDF using DynamicPDF Core Suite for .NET


How to Add EvenOddTemplate to PDF

The following steps and C# sample code illustrate adding an EvenOddTemplate to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding EvenOddTemplate to a PDF Document


  1. Create a Document object.
  2. Create a EvenOddTemplate object.
  3. Add the required page elements to the EvenOddTemplate instance.
  4. Assign the EvenOddTemplate instance to the Document instance.
  5. Add the Draw method to output the PDF document.

Sample Code - C#


Document myDoc = new();
myDoc.Pages.Add(new Page());
myDoc.Pages.Add(new Page());
myDoc.Pages.Add(new Page());
EvenOddTemplate tmp = new EvenOddTemplate();
tmp.EvenElements.Add(new Label("ODD", 0, 0, 200, 12));
tmp.OddElements.Add(new Label("EVEN", 0, 0, 200, 12));
myDoc.Template = tmp;
myDoc.Draw("Output.pdf");


Even odd template added to PDF


How to Add HeaderFooterTemplate to PDF

The following steps and C# sample code illustrate adding an HeaderFooterTemplate to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding HeaderFooterTemplate to a PDF Document


  1. Create a Document object.
  2. Create a HeaderFooterTemplate object.
  3. Add the required page elements to the HeaderFooterTemplate instance.
  4. Assign the HeaerFooterTemplate instance to the Document instance.
  5. Add the Draw method to output the PDF document.

Sample Code - C#


Document myDoc = new();
myDoc.Pages.Add(new Page());
HeaderFooterTemplate header = new HeaderFooterTemplate("Header text", "Footer text");
HeaderFooterText leftText = new HeaderFooterText("Example Header");
header.HeaderLeft = leftText;
myDoc.Template = header;
header.FooterLeft = header.FooterCenter;
myDoc.Draw("output.pdf");


header footer template added to PDF


GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub


Clone or View Example Project on GitHub

Getting Started

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.


NuGet Package


The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information


DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!



More Information on Templates

Available on Other Platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.


Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!