Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# DocumentImage.toBuffer Method

Module: DocumentImage

## Definition

Exports the image to a buffer.

The compression level meaning depends on the algorithm used:

- For JPEG compression, the value is the expected quality and may vary from 1 to 100.

- For JPEG2000 compression, the value is the compression rate and may vary from 1 to 512.

- For PNG compression, the value is the compression rate and may vary from 1 to 10.

- For all other formats, the value is ignored.

Python

    to_buffer(self, document_image_format: ImageFormat, compression_level: float) -> bytearray

Parameters

> `document_image_format` ImageFormat
> in The image format to export the image to.
> `compression_level` float
> in The compression level to be applied.

Returns

> `bytearray`
> Buffer that receives the image data.

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Dart

    Uint8List toBuffer(ImageFormat documentImageFormat, double compressionLevel)

Parameters

> `documentImageFormat` ImageFormat
> in The image format to export the image to.
> `compressionLevel` double
> in The compression level to be applied.

Returns

> `Uint8List`
> Buffer that receives the image data.

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

C#

    public byte[] ToBuffer(ImageFormat documentImageFormat, float compressionLevel)

Parameters

> `documentImageFormat` ImageFormat
> in The image format to export the image to.
> `compressionLevel` float
> in The compression level to be applied.

Returns

> `byte[]`
> Buffer that receives the image data.

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Java

    public byte[] toBuffer(ImageFormat documentImageFormat, float compressionLevel) throws DocumentException

Parameters

> `documentImageFormat` ImageFormat
> in The image format to export the image to.
> `compressionLevel` float
> in The compression level to be applied.

Returns

> `byte[]`
> Buffer that receives the image data.

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

Swift

    public func toBuffer(documentImageFormat: ImageFormat, compressionLevel: Float) throws -> [UInt8]

Parameters

> `documentImageFormat` ImageFormat
> in The image format to export the image to.
> `compressionLevel` Float
> in The compression level to be applied.

Returns

> `[UInt8]`
> Buffer that receives the image data.

Exceptions

> DocumentException
> An error has occurred during Document Library execution.

C

    int id3DocumentImage_ToBuffer (
        ID3_DOCUMENT_IMAGE hDocumentImage,
        id3DocumentImageFormat eDocumentImageFormat,
        float compressionLevel,
        unsigned char * data,
        int * dataSize)

Parameters

> `hDocumentImage` ID3_DOCUMENT_IMAGE
> in Handle to the DocumentImage object.
> `eDocumentImageFormat` id3DocumentImageFormat
> in The image format to export the image to.
> `compressionLevel` float
> in The compression level to be applied.
> `data` unsigned char *
> out Buffer that receives the image data.
> `dataSize` int *
> in Size of the ‘data’ buffer. Receives the number of elements in the ‘data’ array.

Returns

> `int`
> An error code.
> See id3DocumentError file for the list of possible error codes.