Table of Contents

Method CreateImage

Namespace
BitMiracle.Docotic.Pdf
Assembly
BitMiracle.Docotic.Pdf.dll

CreateImage(byte[])

Creates a new image from the provided image data in byte array format.

public PdfImage CreateImage(byte[] imageBytes)

Parameters

imageBytes byte[]

The byte array containing the image file data.

Returns

PdfImage

A new PdfImage object created from the provided image data.

Remarks

This method creates images from data in JPEG, BMP, GIF, PNG, TIFF, and JPEG 2000 formats.

If the data contains an image with multiple frames (pages), like multi-page TIFF or GIF, the method creates a PdfImage object for the first frame only.

Use one of the OpenImage methods to load more than one page of a multipage image. You can further process the frames created by the OpenImage methods before creating PdfImage objects from them.

The Images section describes ways to add images to PDF documents.

You can make certain pixels of the created image transparent. Use the MakeTransparent(PdfColor) method to specify the color of pixels you would like transparent. To set a stencil or a soft mask for the image, use the Mask property.

Check out the sample code for the transparent pixels approach. There is another sample code that shows how to apply image masks.

Exceptions

UnsupportedImageException

The library can not create a PDF image from the provided data. Please send us the image data for a review.

ArgumentNullException

imageBytes is null.

CreateImage(string)

Creates a new image from the specified image file.

public PdfImage CreateImage(string imageFilePath)

Parameters

imageFilePath string

The path to the image file.

Returns

PdfImage

A new PdfImage object created from the provided image data.

Remarks

This method creates images from data in JPEG, BMP, GIF, PNG, TIFF, and JPEG 2000 formats.

If the data contains an image with multiple frames (pages), like multi-page TIFF or GIF, the method creates a PdfImage object for the first frame only.

Use one of the OpenImage methods to load more than one page of a multipage image. You can further process the frames created by the OpenImage methods before creating PdfImage objects from them.

The Images section describes ways to add images to PDF documents.

You can make certain pixels of the created image transparent. Use the MakeTransparent(PdfColor) method to specify the color of pixels you would like transparent. To set a stencil or a soft mask for the image, use the Mask property.

Check out the sample code for the transparent pixels approach. There is another sample code that shows how to apply image masks.

Exceptions

UnsupportedImageException

The library can not create a PDF image from the specified image file. Please send us the image file for a review.

ArgumentNullException

imageFilePath is null.

FileNotFoundException

Thrown if the image file does not exist at the specified path.

CreateImage(Stream)

Creates a new image from the provided stream containing image file data.

public PdfImage CreateImage(Stream imageStream)

Parameters

imageStream Stream

The stream containing the image file data.

Returns

PdfImage

A new PdfImage object created from the provided image data.

Remarks

This method creates images from data in JPEG, BMP, GIF, PNG, TIFF, and JPEG 2000 formats.

If the data contains an image with multiple frames (pages), like multi-page TIFF or GIF, the method creates a PdfImage object for the first frame only.

Use one of the OpenImage methods to load more than one page of a multipage image. You can further process the frames created by the OpenImage methods before creating PdfImage objects from them.

The Images section describes ways to add images to PDF documents.

You can make certain pixels of the created image transparent. Use the MakeTransparent(PdfColor) method to specify the color of pixels you would like transparent. To set a stencil or a soft mask for the image, use the Mask property.

Check out the sample code for the transparent pixels approach. There is another sample code that shows how to apply image masks.

Exceptions

UnsupportedImageException

The library can not create a PDF image from the specified image data. Please send us the image data for a review.

ArgumentNullException

imageStream is null.

CreateImage(PdfImageFrame)

Creates a new image from the provided PdfImageFrame.

public PdfImage CreateImage(PdfImageFrame frame)

Parameters

frame PdfImageFrame

The image frame.

Returns

PdfImage

A new PdfImage object created from the provide image frame.

Remarks

Use one of the OpenImage methods to construct frames from an image with single or multiple frames (pages). Then you can set up compression options for all or selected frames before creating PdfImage objects from them.

The Images section describes ways to add images to PDF documents.

You can make certain pixels of the created image transparent. Use the MakeTransparent(PdfColor) method to specify the color of pixels you would like transparent. To set a stencil or a soft mask for the image, use the Mask property.

See how to change the compression scheme of an image data before creating an PdfImage from it. There is another example for using selected pages (frames) from a multi-page image.

Exceptions

UnsupportedImageException

The library can not create a PDF image from the specified PdfImageFrame. Please send us the image data used to create the frame for a review.

PdfException

There is already an image created from the specified frame.

ArgumentNullException

frame is null.