insertBlankPage method

Future<bool> insertBlankPage({
  1. required int pageIndex,
  2. CPDFPageSize pageSize = CPDFPageSize.a4,
})

Inserts a blank page at the specified index in the document.

This method allows adding a blank page of a specified size at a specific index within the PDF document. It is useful for document editing scenarios where page insertion is needed.

Parameters:

  • pageIndex: The index position where the blank page will be inserted. Must be a valid index within the document.
  • pageSize: The size of the blank page to insert. Defaults to A4 size if not specified. Custom page sizes can be used by creating an instance of CPDFPageSize with custom dimensions.

Returns:

  • A boolean value indicating the success or failure of the blank page insertion. True if the insertion was successful, false otherwise.

example:

CPDFPageSize pageSize = CPDFPageSize.a4;
// custom page size
// CPDFPageSize.custom(500, 800);
bool insertResult = await controller.document.insertBlankPage(pageIndex: 0, pageSize = pageSize);

Implementation

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