Search Results for

    Show / Hide Table of Contents

    Class ImageToPdfConverter

    Converts images (PNG, JPG, BMP, GIF, TIFF, SVG) to professional PDF documents instantly. Perfect for digitizing scanned documents, photo albums, certificates, or creating image portfolios.

    // Single image to PDF:
    var pdf = ImageToPdfConverter.ImageToPdf("photo.jpg");
    pdf.SaveAs("photo.pdf");
    
    // Multiple images to multi-page PDF:
    string[] images = { "page1.png", "page2.jpg", "page3.tiff" };
    var document = ImageToPdfConverter.ImageToPdf(images);
    document.SaveAs("album.pdf");
    
    // From bitmap with custom behavior:
    using (var bitmap = AnyBitmap.FromFile("scan.png")) {
        var pdf = ImageToPdfConverter.ImageToPdf(bitmap,
            Imaging.ImageBehavior.CropPage);  // Exact size
    }

    Supports 20+ image formats including PNG, JPG, GIF, BMP, TIFF, SVG, WebP

    For PDF to image conversion, use PdfDocument.ToBitmap() instead

    See: https://ironpdf.com/how-to/image-to-pdf/

    Inheritance
    System.Object
    ImageToPdfConverter
    Namespace: IronPdf
    Assembly: IronPdf.dll
    Syntax
    public static class ImageToPdfConverter : Object

    Methods

    ImageToPdf(AnyBitmap, ImageBehavior, ChromePdfRenderOptions)

    Converts in-memory bitmap images to PDF without file I/O for maximum performance. Essential for processing generated images, screenshots, or modified graphics.

    // From generated chart:
    using (var chart = GenerateChart()) {
        var pdf = ImageToPdfConverter.ImageToPdf(chart);
        pdf.SaveAs("chart-report.pdf");
    }
    
    // Process screenshot:
    using (var screenshot = CaptureScreen()) {
        var pdf = ImageToPdfConverter.ImageToPdf(screenshot,
            Imaging.ImageBehavior.FitToPageAndMaintainAspectRatio);
        pdf.AddHeader("Screenshot taken: {date}");
        pdf.SaveAs("screenshot.pdf");
    }
    
    // Modified image:
    using (var original = AnyBitmap.FromFile("original.jpg")) {
        // Apply modifications...
        var pdf = ImageToPdfConverter.ImageToPdf(original);
        pdf.SaveAs("modified.pdf");
    }

    Always dispose AnyBitmap objects to prevent memory leaks

    CenteredOnPage default maintains original dimensions

    Declaration
    public static PdfDocument ImageToPdf(AnyBitmap image, ImageBehavior behavior, ChromePdfRenderOptions options = null)
    Parameters
    Type Name Description
    IronSoftware.Drawing.AnyBitmap image

    The image object. Requires a project reference to the IronSoftware.System.Drawing Assembly.

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    ChromePdfRenderOptions options

    Rendering options

    Returns
    Type Description
    PdfDocument

    Returns a PdfDocument document which can then be edited, saved or served over the web.

    Exceptions
    Type Condition
    System.NotSupportedException

    The file does not have a supported image format. Supported files: .apng, .avif, .bmp, .cur, .dib, .gif, .ico, .jfif, .jif, .jpe, .jpeg, .jpg, .pjp, .pjpeg, .png, .svg, .tif, .tiff, .webp

    System.IO.FileNotFoundException

    ImageToPdf(IEnumerable<AnyBitmap>, ImageBehavior, ChromePdfRenderOptions)

    Batch processes multiple in-memory bitmaps to create multi-page PDFs efficiently. Perfect for combining generated graphics, processed images, or dynamic visual content.

    // Generate report with multiple charts:
    var charts = new List<AnyBitmap>();
    foreach (var dataset in datasets) {
        charts.Add(GenerateChart(dataset));
    }
    var report = ImageToPdfConverter.ImageToPdf(charts);
    report.SaveAs("charts-report.pdf");
    // Remember to dispose bitmaps
    charts.ForEach(c => c.Dispose());
    
    // Process batch of screenshots:
    var screenshots = CaptureAllScreens();
    using (var pdf = ImageToPdfConverter.ImageToPdf(screenshots,
        Imaging.ImageBehavior.FitToPageAndMaintainAspectRatio)) {
        pdf.AddWatermark("SCREEN CAPTURE");
        pdf.SaveAs("all-screens.pdf");
    }
    
    // Combine processed images:
    var processed = images.Select(ApplyFilters).ToList();
    var portfolio = ImageToPdfConverter.ImageToPdf(processed);

    Use LINQ to transform images before conversion

    Dispose all AnyBitmap objects after conversion to free memory

    See: https://ironpdf.com/how-to/image-to-pdf/#in-memory-conversion

    Declaration
    public static PdfDocument ImageToPdf(IEnumerable<AnyBitmap> images, ImageBehavior behavior, ChromePdfRenderOptions options = null)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<IronSoftware.Drawing.AnyBitmap> images

    The image objects. Requires a project reference to the IronSoftware.System.Drawing Assembly.

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    ChromePdfRenderOptions options

    Rendering options

    Returns
    Type Description
    PdfDocument

    Returns a PdfDocument document which can then be edited, saved or served over the web.

    Exceptions
    Type Condition
    System.NotSupportedException

    The file does not have a supported image format. Supported files: .apng, .avif, .bmp, .cur, .dib, .gif, .ico, .jfif, .jif, .jpe, .jpeg, .jpg, .pjp, .pjpeg, .png, .svg, .tif, .tiff, .webp

    System.IO.FileNotFoundException

    ImageToPdf(IEnumerable<String>, ImageBehavior, ChromePdfRenderOptions)

    Batch converts multiple images to a multi-page PDF document with one image per page. Ideal for creating photo albums, scanned document bundles, or presentation handouts.

    // Create photo album:
    var photos = Directory.GetFiles(@"C:\Photos", "*.jpg");
    var album = ImageToPdfConverter.ImageToPdf(photos);
    album.SaveAs("vacation-album.pdf");
    
    // Combine scanned pages:
    string[] scans = { "page1.tiff", "page2.tiff", "page3.tiff" };
    var document = ImageToPdfConverter.ImageToPdf(scans,
        Imaging.ImageBehavior.CropPage);  // Preserve exact scan dimensions
    
    // Mixed format portfolio:
    var images = new[] { "cover.png", "chart.svg", "photo.jpg" };
    var portfolio = ImageToPdfConverter.ImageToPdf(images);
    portfolio.AddWatermark("CONFIDENTIAL");
    portfolio.SaveAs("portfolio.pdf");

    Page order matches input array order - pre-sort if needed

    Large images may increase PDF size - consider compression

    See: https://ironpdf.com/examples/image-to-pdf-csharp/

    Declaration
    public static PdfDocument ImageToPdf(IEnumerable<string> imageFileNames, ImageBehavior behavior, ChromePdfRenderOptions options = null)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.String> imageFileNames

    The image file path names.

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    ChromePdfRenderOptions options

    Rendering options

    Returns
    Type Description
    PdfDocument

    Returns a PdfDocument document which can then be edited, saved or served over the web.

    Exceptions
    Type Condition
    System.NotSupportedException

    The file does not have a supported image format. Supported files: .apng, .avif, .bmp, .cur, .dib, .gif, .ico, .jfif, .jif, .jpe, .jpeg, .jpg, .pjp, .pjpeg, .png, .svg, .tif, .tiff, .webp

    System.IO.FileNotFoundException

    ImageToPdf(String, ImageBehavior, ChromePdfRenderOptions)

    Converts a single image file to a high-quality PDF document instantly. Automatically handles aspect ratio, orientation, and resolution for professional results.

    // Simple conversion:
    var pdf = ImageToPdfConverter.ImageToPdf("invoice-scan.jpg");
    pdf.SaveAs("invoice.pdf");
    
    // Custom page layout:
    var options = new ChromePdfRenderOptions {
        PaperSize = PdfPaperSize.A4,
        MarginTop = 0, MarginBottom = 0,
        MarginLeft = 0, MarginRight = 0
    };
    var pdf = ImageToPdfConverter.ImageToPdf("certificate.png",
        Imaging.ImageBehavior.CropPage, options);
    
    // Fit to page with margins:
    var pdf = ImageToPdfConverter.ImageToPdf("diagram.svg",
        Imaging.ImageBehavior.FitToPageAndMaintainAspectRatio);

    CropPage creates exact image dimensions, FitToPage uses standard paper sizes

    SVG files are rendered at high quality regardless of size

    Declaration
    public static PdfDocument ImageToPdf(string imageFileName, ImageBehavior behavior, ChromePdfRenderOptions options = null)
    Parameters
    Type Name Description
    System.String imageFileName

    File path of the image file.

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    ChromePdfRenderOptions options

    Rendering options

    Returns
    Type Description
    PdfDocument

    Returns a PdfDocument document which can then be edited, saved or served over the web.

    Exceptions
    Type Condition
    System.NotSupportedException

    The file does not have a supported image format. Supported files: .apng, .avif, .bmp, .cur, .dib, .gif, .ico, .jfif, .jif, .jpe, .jpeg, .jpg, .pjp, .pjpeg, .png, .svg, .tif, .tiff, .webp

    System.IO.FileNotFoundException
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronPDF to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronPDF free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.