processAnnotations static method

Future<bool> processAnnotations({
  1. required String sourcePath,
  2. required AnnotationType type,
  3. required AnnotationProcessingMode mode,
  4. required String destinationPath,
  5. NutrientController? adapter,
})

Processes the annotations of the document at sourcePath and writes the result to destinationPath, mirroring the legacy SDK's Nutrient.processAnnotations.

type selects which annotations to process (use AnnotationType.all for every annotation); mode chooses how — flatten, remove, embed, or print. The source document is opened and released internally, so no open document or viewer is required.

In-place processing (sourcePath == destinationPath) is supported: the result is written to a sibling temp file and moved over the destination only after processing succeeds, so the original is preserved on failure. A pre-existing file at a distinct destinationPath is likewise only replaced by a complete output, never deleted up front.

The native processing runs in a short-lived background isolate — the whole document is rewritten synchronously on the processing thread, so this keeps the UI responsive during large jobs.

Supported on Android and iOS. Not supported on Web (throws UnsupportedError). Pass adapter to host the operation on a specific controller; otherwise the platform default adapter is used.

await Nutrient.processAnnotations(
  sourcePath: 'in.pdf',
  type: AnnotationType.all,
  mode: AnnotationProcessingMode.flatten,
  destinationPath: 'out.pdf',
);

Implementation

static Future<bool> processAnnotations({
  required String sourcePath,
  required AnnotationType type,
  required AnnotationProcessingMode mode,
  required String destinationPath,
  NutrientController? adapter,
}) =>
    _headlessHost(adapter)
        .processAnnotations(sourcePath, type, mode, destinationPath);