Examples

Add Image to PDF (.NET Core/Framework)

Images can be added to a PDF easily using the DynamicPDF Generator product. Different image formats (GIF, JPEG, JPG, JPEG2000, PNG, BMP, EMF, EXIF, TIFF, Multi Page Tiff, TIFF to PDF, WMF and Transparent Images) can be added to a PDF document.

How to add an Image to PDF in C#

Below are the steps and sample code to add an image to PDF document using the Generator product.

Steps for adding an image to PDF Document

  1. Create a Document object.
  2. Create and add a Page to the document.
  3. Create an Image object.
  4. Add the Image to the Page.
  5. Save the PDF document.

Sample Code - C#

Document document = new Document();
 
Page page = new Page();
document.Pages.Add(page);
 
Image image = new Image(@"C:\MyImage.jpg", 0, 0);
page.Elements.Add(image);
 
document.Draw(@"C:\MyDocument.pdf");

How to add Background Image to PDF in C#

Adding Background Image to PDF using DynamicPDF Generator is simple and easy. BackgroundImage class can be used to place an image on the page that will be stretched to the dimensions of the page. Below are the steps and sample code to add a Background Image to PDF document using the Generator product.

Steps for Adding Background Image to a PDF Document

  1. Create a Document object.
  2. Create a Page object and add it to the Document.
  3. Create a BackgroundImage object by specifying the image path.
  4. Place the image within the page margins.
  5. Add BackgroundImage to the Page.
  6. Save the PDF.

Sample Code - C#

Document document = new Document();
            
Page page = new Page();
document.Pages.Add(page);
            
BackgroundImage backgroundImage = new BackgroundImage(imagePath);
            
backgroundImage.UseMargins = true;
            
page.Elements.Add(backgroundImage);
            
document.Draw(@"C:\Output.pdf");

Getting Started

NuGet Package

DynamicPDF Generator is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF CoreSuite Information

More information on DynamicPDF CoreSuite can be found here:

Java and COM/ActiveX Platforms

The DynamicPDF Generator is also available for Java and COM/ActiveX. 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 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

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