openCustom static method

Future<PdfDocument> openCustom({
  1. required FutureOr<int> read(
    1. Uint8List buffer,
    2. int position,
    3. int size
    ),
  2. required int fileSize,
  3. required String sourceName,
  4. PdfPasswordProvider? passwordProvider,
  5. bool firstAttemptByEmptyPassword = true,
  6. int? maxSizeToCacheOnMemory,
  7. void onDispose()?,
})

Opening the PDF from custom source.

maxSizeToCacheOnMemory is the maximum size of the PDF to cache on memory in bytes; the custom loading process may be heavy because of FFI overhead and it may be better to cache the PDF on memory if it's not too large. The default size is 1MB.

passwordProvider is used to provide password for encrypted PDF. See PdfPasswordProvider for more info. firstAttemptByEmptyPassword is used to determine whether the first attempt to open the PDF is by empty password or not. For more info, see PdfPasswordProvider.

sourceName can be any arbitrary string to identify the source of the PDF; Neither of read/fileSize identify the source if such name is explicitly specified.

Implementation

static Future<PdfDocument> openCustom({
  required FutureOr<int> Function(Uint8List buffer, int position, int size)
      read,
  required int fileSize,
  required String sourceName,
  PdfPasswordProvider? passwordProvider,
  bool firstAttemptByEmptyPassword = true,
  int? maxSizeToCacheOnMemory,
  void Function()? onDispose,
}) =>
    PdfDocumentFactory.instance.openCustom(
      read: read,
      fileSize: fileSize,
      sourceName: sourceName,
      passwordProvider: passwordProvider,
      firstAttemptByEmptyPassword: firstAttemptByEmptyPassword,
      maxSizeToCacheOnMemory: maxSizeToCacheOnMemory,
      onDispose: onDispose,
    );