PngDevice

Inheritance: java.lang.Object, com.aspose.pdf.devices.Device, com.aspose.pdf.devices.PageDevice, com.aspose.pdf.devices.ImageDevice

public final class PngDevice extends ImageDevice

Represents image device that helps to save pdf document pages into png.

Constructors

ConstructorDescription
PngDevice()Initializes a new instance of the PngDevice class with default resolution.
PngDevice(Resolution resolution)Initializes a new instance of the PngDevice class.
PngDevice(int width, int height, Resolution resolution)Initializes a new instance of the PngDevice class with provided image dimensions and resolution.
PngDevice(PageSize pageSize, Resolution resolution)Initializes a new instance of the PngDevice class with provided page size and resolution.
PngDevice(int width, int height)Initializes a new instance of the PngDevice class with provided image dimensions, default resolution (=150).
PngDevice(PageSize pageSize)Initializes a new instance of the PngDevice class with provided page size, default resolution (=150).

Methods

MethodDescription
isTransparentBackground()Gets or sets if image has transparent background.
setTransparentBackground(boolean value)Gets or sets if image has transparent background.
processInternal(Page page, System.IO.Stream output)Converts the page into png and saves it in the output stream.
process(Page page, OutputStream output)Converts the page into png and saves it in the output stream.
processToBufferedImage(Page page)Converts the page into BufferedImage.
processToBufferedImageBinarized(Page page, double threshold)Converts the page into BufferedImage with Bradley binarization.

PngDevice()

public PngDevice()

Initializes a new instance of the PngDevice class with default resolution.

PngDevice(Resolution resolution)

public PngDevice(Resolution resolution)

Initializes a new instance of the PngDevice class.

Parameters:

ParameterTypeDescription
resolutionResolutionResolution for the result image file, see Resolution class.

PngDevice(int width, int height, Resolution resolution)

public PngDevice(int width, int height, Resolution resolution)

Initializes a new instance of the PngDevice class with provided image dimensions and resolution.

Parameters:

ParameterTypeDescription
widthintImage output width.
heightintImage output height.
resolutionResolutionResolution for the result image file, see Resolution class.

PngDevice(PageSize pageSize, Resolution resolution)

public PngDevice(PageSize pageSize, Resolution resolution)

Initializes a new instance of the PngDevice class with provided page size and resolution.

Parameters:

ParameterTypeDescription
pageSizePageSizePage size of the output image.
resolutionResolutionResolution for the result image file, see Resolution class.

PngDevice(int width, int height)

public PngDevice(int width, int height)

Initializes a new instance of the PngDevice class with provided image dimensions, default resolution (=150).

Parameters:

ParameterTypeDescription
widthintImage output width.
heightintImage output height.

PngDevice(PageSize pageSize)

public PngDevice(PageSize pageSize)

Initializes a new instance of the PngDevice class with provided page size, default resolution (=150).

Parameters:

ParameterTypeDescription
pageSizePageSizePage size of the output image.

isTransparentBackground()

public final boolean isTransparentBackground()

Gets or sets if image has transparent background.

Returns: boolean - boolean value

setTransparentBackground(boolean value)

public final void setTransparentBackground(boolean value)

Gets or sets if image has transparent background.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

processInternal(Page page, System.IO.Stream output)

public void processInternal(Page page, System.IO.Stream output)

Converts the page into png and saves it in the output stream.

Parameters:

ParameterTypeDescription
pagePageThe page to convert.
outputcom.aspose.ms.System.IO.StreamOutput stream with png image.

process(Page page, OutputStream output)

public void process(Page page, OutputStream output)

Converts the page into png and saves it in the output stream.

Parameters:

ParameterTypeDescription
pagePageThe page to convert.
outputjava.io.OutputStreamOutput stream with png image.

processToBufferedImage(Page page)

public BufferedImage processToBufferedImage(Page page)

Converts the page into BufferedImage.

Parameters:

ParameterTypeDescription
pagePageThe page to convert.

Returns: java.awt.image.BufferedImage - BufferedImage Output BufferedImage image.

processToBufferedImageBinarized(Page page, double threshold)

public BufferedImage processToBufferedImageBinarized(Page page, double threshold)

Converts the page into BufferedImage with Bradley binarization.

Parameters:

ParameterTypeDescription
pagePageThe page to convert.
thresholddoubleThe threshold value between 0.0 and 1.0.

Returns: java.awt.image.BufferedImage - BufferedImage Output BufferedImage image.