How to use Save As for PDFs in Flutter

It’s not uncommon for customers to want a setup where a document is read-only but users can still edit it and then use the Save As functionality to save the modified document to a new location. Nutrient supports saving documents with the Save As functionality.

After displaying a document on Flutter using either PspdfkitWidget(opens in a new tab) or Pspdfkit.present()(opens in a new tab), Save As can be implemented by following these steps:

PspdfkitWidget and PspdfkitWidgetController

The code for this on Dart looks something like this:

@override
Widget build(BuildContext context) {
// ...
return Scaffold(
// ...
body: Column(children: [
Expanded(
child: PspdfkitWidget(
document: documentPath,
configuration: configuration,
onCreated: onPlatformViewCreated),
SizedBox(
child: ElevatedButton(
onPressed: () async {
// Ensure that the path for the new document is a writable path.
// You can use a package like https://pub.dev/packages/filesystem_picker to allow users to select the directory and name of the file to save.
final newDocumentPath = await getExportPath(
'PDFs/Embedded/new_pdf_document.pdf');
await pspdfkitWidgetController.processAnnotations(
'all', 'embed', newDocumentPath);
print(
'Document has been saved to $newDocumentPath');
},
child: const Text('Save Document As'))
))]
));
// ...
}
// ...
// This method is part of the custom widget's class.
Future<void> onPlatformViewCreated(controller) async {
pspdfkitWidgetController = controller;
}

Save As is currently only available on iOS. Support for Save As on Android is coming soon.