Supported document save options in Flutter
Use DocumentSaveOptions to control how Nutrient Flutter SDK saves and exports documents. Pass it to save() or exportPdf() on the viewer’s controller.document, or on a document you opened headlessly with Nutrient.openDocument(). Refer to the document save options(opens in a new tab) API reference for details.
The following save options are available. Every field is optional. If you omit a field, the SDK uses its default value.
| Option | Applies to | Description |
|---|---|---|
userPassword | All | Sets the user password (or open password) and encrypts the output PDF. |
ownerPassword | All | Sets the owner password (or permissions password) for the output PDF. |
permissions | All | Sets permitted operations on the encrypted document. |
flatten | All | Bakes annotations and form fields into the page content. |
incremental | Android, iOS, Web (standalone) | Appends changes instead of rewriting the whole file. |
excludeAnnotations | All | Omits annotations from the saved file. |
saveForPrinting | Standalone | Prepares the output for printing. |
pdfVersion | Android, iOS | Sets the target PDF version, from pdf_1_0 to pdf_1_7. Web ignores this. |
includeComments | Web (server-backed) | Includes comments in the exported document. |
outputFormat | Web, standalone | Overrides the output format, for example, 'pdf/a-2b' for PDF/A. |
optimize | Android, Web (server-backed) | Prepares the document for web delivery. |
Refer to the document permissions(opens in a new tab) and PDF version(opens in a new tab) API references for supported permissions and pdfVersion values.
Save with options
Use DocumentSaveOptions with save() to save a document with custom options. You can also provide an outputPath to save to a different location. Refer to the save(opens in a new tab) API reference for details.
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, ),);Export with options
Use DocumentSaveOptions with exportPdf() to export a document copy as binary data. Refer to the export PDF(opens in a new tab) API reference for details.
final data = await document.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).