insertPageWithImagePath method

Future<bool> insertPageWithImagePath({
  1. required int pageIndex,
  2. required String imagePath,
  3. CPDFPageSize pageSize = CPDFPageSize.a4,
})

Inserts a new PDF page at the specified index using an image from a file path.

The image located at imagePath will be used to create a new page, which will be inserted at pageIndex in the current PDF document.

pageSize specifies the size of the new page. Defaults to A4 size.

example:

bool result = await controller.document.insertPageWithImagePath(
  pageIndex: 0,
  imagePath: '/path/to/image.png',
  pageSize: CPDFPageSize.a4,
 );

Returns true if the page is successfully inserted, otherwise false. Throws a PlatformException if the native platform reports an error.

Implementation

Future<bool> insertPageWithImagePath({
  required int pageIndex,
  required String imagePath,
  CPDFPageSize pageSize = CPDFPageSize.a4,
}) async {
  return await _channel.invokeMethod('insert_page_with_image_path', {
    'page_index': pageIndex,
    'image_path': imagePath,
    'page_width': pageSize.width,
    'page_height': pageSize.height
  });
}