DocumentSaveOptions(opens in a new tab) provides control over how documents are saved and exported. Pass it to PdfDocument.save() or PdfDocument.exportPdf() on Android and iOS to customize document properties during the save process.

The following save options are available:

  • flatten — Visually embeds annotations and form fields in a document and removes them from the document’s data.
  • incremental — Forces a document to be incrementally saved if true.
  • excludeAnnotations — Excludes annotations from a saved or exported document.
  • saveForPrinting — Excludes annotations that have the noPrint flag set to true.
  • permissions — Protects a PDF with a password and sets the permissions for the document.
  • outputFormat — Saves or exports a PDF in PDF/A format.
  • userPassword — Sets the user password for a document.
  • ownerPassword — Sets the owner password for a document.

Saving with options

Use DocumentSaveOptions with PdfDocument.save() to save a document with custom options. Optionally, provide an outputPath to save to a different location:

final document = await Nutrient.openDocument(documentPath);
// Save in place with options.
await document.save(
options: DocumentSaveOptions(
flatten: true,
incremental: false,
excludeAnnotations: false,
),
);
// Save to a different path.
await document.save(
outputPath: '/path/to/output.pdf',
options: DocumentSaveOptions(
flatten: true,
),
);

Exporting with options

Use DocumentSaveOptions with PdfDocument.exportPdf() to export a copy of a document as binary data:

final data = await pdfDocument.exportPdf(
options: DocumentSaveOptions(
userPassword: ‘userPassword’,
ownerPassword: ‘ownerPassword’,
flatten: true,
incremental: true,
excludeAnnotations: true,
saveForPrinting: true,
permissions: [
DocumentPermissions.printing,
DocumentPermissions.modification,
],
),
);
// Save the data to a file or upload to a remote server.

For more details about saving a document with Nutrient Flutter SDK, refer to the Catalog example project(opens in a new tab).