rewriteBytes method

Future<PdfRewriteResult> rewriteBytes(
  1. Uint8List bytes, {
  2. bool useIsolate = false,
})

Rewrites the bytes of a PDF.

The file is read with repair enabled, so a damaged xref can still be rewritten — and the rewrite fixes the table, because the output is written from scratch.

Implementation

Future<PdfRewriteResult> rewriteBytes(
  Uint8List bytes, {
  bool useIsolate = false,
}) {
  final source = PdfDocumentParser(bytes, allowRepair: true);
  return rewriteDocument(
    source,
    bytesBefore: bytes.length,
    useIsolate: useIsolate,
  );
}