# toBufferObject method

void toBufferObject(

1. ImageFormat documentImageFormat,
2. double compressionLevel,
3. ImageBuffer buffer

)

Copies the image to a buffer in the specified format. 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.

param documentImageFormat The output image format. param compressionLevel The compression level to be applied. param buffer The image buffer that receives the image data. throws DocumentException An error has occurred during Document Library execution.

## Implementation

    void toBufferObject(ImageFormat documentImageFormat, double compressionLevel, ImageBuffer buffer) {
      var err = documentSDK.id3DocumentImage_ToBufferObject(_pHandle.value, documentImageFormat.value, compressionLevel, buffer.handle);
      if (err != DocumentError.success.value) {
        throw DocumentException(err);
      }
    }