How to Convert Image to PDF in C#

This basic tutorial explains the information about how to convert image to PDF in C#. You can develop a C# image to PDF converter application by following the steps enlisted below and running the code snippet in your project. Moreover, you do not need to install any other image processing application to work with the image conversion feature.

Steps to Convert Image to PDF in C#

  1. Add the reference to Aspose.PDF for .NET library in your application to convert images to PDF file
  2. Create an object of the Document class to initialize an empty PDF file
  3. Initialize an Image class object
  4. Load the input JPG or PNG image for converting it to PDF file format
  5. Save the output PDF document

To export an image to PDF C# based application configuration and detailed steps are discussed here. You can convert different type of images like PNG, JPG, BMP, etc to PDF. Likewise, you can insert an image on any page number in a PDF document simply by providing the page number.

Code to Convert Image to PDF in C#

While working with C# convert image to PDF process uses two main classes where first one is the Document class which contains a collection of pages. We add a new page to this collection and then create an Image class object to load the image from the disk that is the second main class. This image is added to the first paragraph in the newly created page and to convert multiple images to PDF C# code is the same where you can add as many images as required to the selected paragraph.

In this article, we have learned the conversion of an image to a PDF. However, if you want to explore how to convert PDF to Image, refer to the article on how to convert PDF to Image in C#.

 English