Search Results for

    Show / Hide Table of Contents

    Class ImageToPdfConverter

    The ImageToPdfConveter class can be used to create PDF documents from images. It accepts both image files and System.Drawing.Image objects as input.

    The ImageToPdf static methods create simple PDF documents containing each image as one page of the created PDF.

    To rasterize PDF documents as images (the reverse operation), see ToBitmap(Int32) and RasterizeToImageFiles(String, ImageType, Int32)

    Inheritance
    System.Object
    ImageToPdfConverter
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ToString()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: IronPdf
    Assembly: IronPdf.dll
    Syntax
    public static class ImageToPdfConverter

    Methods

    ImageToPdf(IEnumerable<Image>, ImageBehavior, Boolean)

    Converts multiple System.Drawing.Image objects or Bitmaps into a PDF document. Each image creates 1 page which matches the image dimensions.

    Declaration
    public static PdfDocument ImageToPdf(IEnumerable<Image> images, ImageBehavior behavior = ImageBehavior.CenteredOnPage, bool GenerateUniqueDocumentIdentifiers = true)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Drawing.Image> images

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

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    System.Boolean GenerateUniqueDocumentIdentifiers

    if false, System.Guid is not generated inside PDF DOM and BinaryData for two identical PDF files will be the same. This is very useful for Unit Testing, especially comparing rendered PDFs for Equality.

    Returns
    Type Description
    PdfDocument

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

    ImageToPdf(IEnumerable<String>, ImageBehavior, Boolean)

    Converts multiple image files to a PDF document. Each image creates 1 page which matches the image dimensions.

    Declaration
    public static PdfDocument ImageToPdf(IEnumerable<string> imageFileNames, ImageBehavior behavior = ImageBehavior.CenteredOnPage, bool GenerateUniqueDocumentIdentifiers = true)
    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

    System.Boolean GenerateUniqueDocumentIdentifiers

    if false, System.Guid is not generated inside PDF DOM and BinaryData for two identical PDF files will be the same. This is very useful for Unit Testing, especially comparing rendered PDFs for Equality.

    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: .bmp, .dib, .jpg, .jpeg, .jpe, .jfif, .jif, .png, .tiff, .tif, .gif.

    ImageToPdf(Image, ImageBehavior, Boolean)

    Converts a single System.Drawing.Image object or Bitmap to a PDF document of matching dimensions.

    Declaration
    public static PdfDocument ImageToPdf(Image image, ImageBehavior behavior = ImageBehavior.CenteredOnPage, bool GenerateUniqueDocumentIdentifiers = true)
    Parameters
    Type Name Description
    System.Drawing.Image image

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

    ImageBehavior behavior

    Describes how image should be placed on the PDF page

    System.Boolean GenerateUniqueDocumentIdentifiers

    if false, System.Guid is not generated inside PDF DOM and BinaryData for two identical PDF files will be the same. This is very useful for Unit Testing, especially comparing rendered PDFs for Equality.

    Returns
    Type Description
    PdfDocument

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

    ImageToPdf(String, ImageBehavior, Boolean)

    Converts a single image file to an identical PDF document of matching dimensions.

    Declaration
    public static PdfDocument ImageToPdf(string imageFileName, ImageBehavior behavior = ImageBehavior.CenteredOnPage, bool GenerateUniqueDocumentIdentifiers = true)
    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

    System.Boolean GenerateUniqueDocumentIdentifiers

    if false, System.Guid is not generated inside PDF DOM and BinaryData for two identical PDF files will be the same. This is very useful for Unit Testing, especially comparing rendered PDFs for Equality.

    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: .bmp, .dib, .jpg, .jpeg, .jpe, .jfif, .jif, .png, .tiff, .tif, .gif.

    ☀
    ☾
    In This Article
    Back to top
    Install with Nuget