How to Convert Images to a PDF in C#
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.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
IronPdf.ImageToPdfConverter.ImageToPdf("path/to/image.png").SaveAs("imageToPdf.pdf");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the IronPDF C# library for converting images to PDF
- Prepare the image or images you want to convert
- Supply the image path(s) to the
ImageToPdfstatic method - Adjust the image placement and behavior in the output PDF
- Add custom text and HTML header and footer using IronPDF
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?

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?
:path=/static-assets/pdf/content-code-examples/how-to/image-to-pdf-convert-one-image.csusing 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?
:path=/static-assets/pdf/content-code-examples/how-to/image-to-pdf-convert-multiple-images.csusing 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?
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?
:path=/static-assets/pdf/content-code-examples/how-to/image-to-pdf-convert-one-image-image-behavior.csusing 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?
![]()
| ![]()
|
![]()
| ![]()
|
![]()
| ![]()
|
![]()
| ![]()
|
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?
:path=/static-assets/pdf/content-code-examples/how-to/image-to-pdf-convert-one-image-rendering-options.csusing 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
What image formats can be converted to PDF?
IronPDF supports a comprehensive range of image formats for PDF conversion, including .bmp, .jpeg, .jpg, .gif, .png, .svg, .tif, .tiff, .webp, .apng, .avif, .cur, .dib, .ico, .jfif, .jif, .jpe, .pjp, and .pjpeg. This includes both raster formats like JPEG, PNG, BMP, and GIF, as well as vector formats such as SVG graphics.
How do I convert a single image to PDF in C#?
To convert a single image to PDF using IronPDF, use the ImageToPdf static method within the ImageToPdfConverter class. Simply provide the file path to your image: IronPdf.ImageToPdfConverter.ImageToPdf("path/to/image.png").SaveAs("imageToPdf.pdf"). This one-line solution converts your image to a PDF document with default placement and behavior.
Can I convert multiple images into a single PDF document?
Yes, IronPDF enables you to convert multiple images (JPG, PNG, TIFF) into a single PDF document using the ImageToPdfConverter.ImageToPdf method. This is perfect for creating digital portfolios, presentations, or reports where you need to combine several image files into one organized, universally readable PDF format.
What customization options are available when converting images to PDF?
IronPDF offers extensive customization options including unique image placements and behaviors (fitting to page, centering, cropping), adding text and HTML headers and footers, applying watermarks, setting custom page sizes, and including background and foreground overlays. These features allow you to create professional-looking PDF documents from your images.
Which platforms does the image to PDF conversion feature support?
IronPDF's image to PDF conversion works seamlessly across Windows, macOS, and Linux platforms, making it versatile for various development environments. You can install it via NuGet or download the Windows installer to get started on your preferred platform.
How can I control image placement when converting to PDF?
IronPDF provides unique image placements and behaviors including fitting to the page, centering on the page, and cropping the page. These export image behaviors give you precise control over how your images appear in the final PDF document, ensuring professional presentation of your visual content.















