IRONSOFTWAREHOME

How to Convert Images to a PDF in C#

Curtis Chau
Curtis Chau
Updated: September 5, 2026

IronPDF enables C# developers to convert single or multiple images (JPG, PNG, TIFF) into PDF documents using the ImageToPdfConverter.ImageToPdf method with customizable placement behaviors and rendering options.

Converting images to PDF combines multiple image files (such as JPG, PNG, or TIFF) into a single PDF document. This process creates digital portfolios, presentations, or reports, making it easier to share and store image collections in an organized and universally readable format.

IronPDF converts single or multiple images into PDFs with unique image placements and behaviors. These behaviors include fitting to the page, centering on the page, and cropping the page. Additionally, you can add text and HTML headers and footers using IronPDF, apply watermarks with IronPDF, set custom page sizes, and include background and foreground overlays.

Quickstart: Convert Images to PDF with IronPDF

Convert images into PDF documents using IronPDF's ImageToPdfConverter class. This example demonstrates how to transform an image file into a PDF, allowing you to integrate image-to-PDF functionality into your .NET C# applications. With minimal code, you can convert images to PDF for creating digital portfolios or reports.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    IronPdf.ImageToPdfConverter.ImageToPdf("path/to/image.png").SaveAs("imageToPdf.pdf");
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

How Do I Convert a Single Image to PDF?

Use the ImageToPdf static method within the ImageToPdfConverter class to convert an image to a PDF document. This method requires only the file path to the image and converts it to a PDF document with default image placement and behavior. Supported image formats include .bmp, .jpeg, .jpg, .gif, .png, .svg, .tif, .tiff, .webp, .apng, .avif, .cur, .dib, .ico, .jfif, .jif, .jpe, .pjp, and .pjpeg.

Before starting, ensure you have installed IronPDF via NuGet or downloaded the Windows installer. The library works seamlessly across Windows, macOS, and Linux platforms, making it versatile for various development environments.

What Image Formats Are Supported?

Iron Software team members in purple uniforms at company event

IronPDF supports a comprehensive range of image formats, including raster formats like JPEG, PNG, BMP, and GIF, as well as vector formats such as SVG graphics. The library handles both standard and modern formats like WebP and AVIF, ensuring compatibility with contemporary web applications. For specialized needs, work with icon files (.ico) and cursor files (.cur).

How Do I Write the Code?

using IronPdf;

string imagePath = "meetOurTeam.jpg";

// Convert an image to a PDF
PdfDocument pdf = ImageToPdfConverter.ImageToPdf(imagePath);

// Export the PDF
pdf.SaveAs("imageToPdf.pdf");

For more advanced scenarios, explore asynchronous PDF generation to improve performance when processing multiple images. The library also supports custom paper sizes and custom margins to ensure your images display exactly as needed.

What Does the Output Look Like?


How Do I Convert Multiple Images to PDF?

To convert multiple images into a PDF document, provide an IEnumerable object containing file paths instead of a single file path. This generates a PDF document with default image placement and behavior.

When working with multiple images, consider the PDF compression options available to optimize file size without sacrificing quality. This is particularly important when creating large portfolios or photo albums.

How Do I Process Multiple Images at Once?

using IronPdf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

// Retrieve all JPG and JPEG image paths in the 'images' folder.
IEnumerable<String> imagePaths = Directory.EnumerateFiles("images").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg"));

// Convert images to a PDF
PdfDocument pdf = ImageToPdfConverter.ImageToPdf(imagePaths);

// Export the PDF
pdf.SaveAs("imagesToPdf.pdf");

What Does the Multi-Image PDF Look Like?


My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.

Milan Jovanovic

Microsoft MVP

View case study

IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.

Brent Matzelle

Chief Technology Officer, OPYN

View case study

The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.

David Jones

Lead Software Engineer, Agorus Build

View case study

How Can I Control Image Placement and Behaviors?

IronPDF offers various image placement and behavior options. You can center the image on the page or fit it to the page size while maintaining its aspect ratio. All available image placements and behaviors are:

  • ``TopLeftCornerOfPage: Image is placed at the top-left corner of the page.
  • ``TopRightCornerOfPage: Image is placed at the top-right corner of the page.
  • ``CenteredOnPage: Image is centered on the page.
  • ``FitToPageAndMaintainAspectRatio: Image fits the page while keeping its original aspect ratio.
  • ``BottomLeftCornerOfPage: Image is placed at the bottom-left corner of the page.
  • ``BottomRightCornerOfPage: Image is placed at the bottom-right corner of the page.
  • ``FitToPage: Image fits the page.
  • ``CropPage: Page is adjusted to fit the image.

These placement options work seamlessly with IronPDF's page orientation and rotation features, allowing you to create professional-looking documents regardless of your image dimensions.

How Do I Apply Image Behaviors in Code?

using IronPdf;
using IronPdf.Imaging;

string imagePath = "meetOurTeam.jpg";

// Convert an image to a PDF with image behavior of centered on page
PdfDocument pdf = ImageToPdfConverter.ImageToPdf(imagePath, ImageBehavior.CenteredOnPage);

// Export the PDF
pdf.SaveAs("imageToPdf.pdf");

What Are the Visual Differences Between Image Behaviors?

Iron Software team members in purple branded athletic wear at company team event
Iron Software team members in purple branded athletic wear at outdoor company event
Iron Software team members in purple branded athletic wear at company team event
Iron Software team members in purple uniforms at company sporting event
Iron Software team members in purple athletic gear at company sports event with 'Meet our team' overlay
Iron Software team members in purple branded athletic wear at company sports event with branded text overlay
Iron Software team members in purple uniforms at corporate team event with 'Meet our team' text overlay
Iron Software team members in purple branded athletic wear at corporate team event

How Do I Customize PDF Rendering Options?

The ImageToPdf static method converts images by importing them as HTML <img> tags and then converting the HTML to PDF. This allows you to pass the ChromePdfRenderOptions object as a third parameter to customize the rendering process directly.

This approach provides access to all the powerful rendering options available in IronPDF, including JavaScript execution, CSS media types, and viewport configuration. You can even incorporate web fonts and icons to enhance your document's visual appeal.

How Do I Add Headers and Custom Styling?

using IronPdf;

string imagePath = "meetOurTeam.jpg";

ChromePdfRenderOptions options = new ChromePdfRenderOptions()
{
    HtmlHeader = new HtmlHeaderFooter()
    {
        HtmlFragment = "<h1 style='color: #2a95d5;'>Content Header</h1>",
        DrawDividerLine = true,
    },
};

// Convert an image to a PDF with custom header
PdfDocument pdf = ImageToPdfConverter.ImageToPdf(imagePath, options: options);

// Export the PDF
pdf.SaveAs("imageToPdfWithHeader.pdf");

For more complex header and footer requirements, explore our comprehensive guide on HTML headers and footers. You can also add page numbers to your image-based PDFs for better organization.

What Does the Customized Output Look Like?

How Do I Handle Performance and Large Image Collections?

When dealing with large image collections or high-resolution images, implement async and multithreading techniques to improve performance. For enterprise applications, explore IronPDF's performance optimization strategies to ensure smooth operation even with substantial workloads.

Additionally, when working with images stored in cloud services, check our guide on embedding images from Azure Blob Storage for seamless cloud integration.

How Do I Convert PDFs Back to Images?

To convert or rasterize a PDF document into images, refer to our guide on how to rasterize PDFs to images.

Ready to see what else you can do? Check out our tutorial page here: Convert PDFs

Frequently Asked Questions

How can I convert a single image to PDF in C# using IronPDF?

To convert a single image to PDF, use the `ImageToPdf` static method within the `ImageToPdfConverter` class. You need to supply the file path of the image, and the method will handle the conversion with default image placement and behavior. Supported formats include .bmp, .jpeg, .jpg, .png, and more.

What are the supported image formats for conversion using IronPDF?

IronPDF supports a wide range of image formats, including raster formats like JPEG, PNG, BMP, and GIF, as well as vector formats like SVG. It also supports standard and modern formats such as WebP and AVIF, ensuring enhanced compatibility across web applications.

Can I convert multiple images into a single PDF document with IronPDF?

Yes, you can convert multiple images into a single PDF by providing an `IEnumerable` object containing the file paths of the images to the `ImageToPdf` method. This allows you to generate a PDF document with all the images.

How do I customize image placement and behaviors in the PDF using IronPDF?

IronPDF provides various image placement options like centering on the page, fitting to the page while maintaining the aspect ratio, and placing images at specific corners. You can select these behaviors to ensure your images appear as desired in the PDF.

Can I add custom headers and footers when converting images to PDF with IronPDF?

Yes, IronPDF allows you to add text and HTML headers and footers to your PDF. You can customize these elements to include page numbers or other relevant information, enhancing the presentation and organization of your document.

How do I handle large image collections for PDF conversion in IronPDF?

For large image collections or high-resolution images, it's beneficial to implement async and multi-threading techniques to boost performance. IronPDF supports these methods to ensure efficient processing even with substantial workloads.

What are the rendering customization options available in IronPDF?

IronPDF allows you to use the `ChromePdfRenderOptions` object to customize the rendering process. This includes options like JavaScript execution, CSS media types, and custom headers. You can also incorporate web fonts and icons for a more polished document.

Is it possible to convert a PDF back to an image using IronPDF?

Yes, IronPDF supports converting or rasterizing PDF documents back into images. This can be useful for various applications that require different formats for distribution or presentation.

Can IronPDF work on different operating systems?

IronPDF is versatile and can operate seamlessly across Windows, macOS, and Linux environments, making it an excellent choice for various development platforms.

How do I optimize PDF size when combining multiple images using IronPDF?

IronPDF offers PDF compression options to optimize the file size when merging multiple images. It's especially useful when creating large digital portfolios or photo albums, ensuring quality is maintained without large file sizes.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,062,892Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999