saveAs method

Future<bool> saveAs(
  1. String savePath, {
  2. bool removeSecurity = false,
  3. bool fontSubSet = true,
})

Saves the document to the specified directory.

Example usage:

await controller.document.saveAs('data/your_package_name/files/xxx.pdf')
  • savePath Specifies the path where the document should be saved. On Android, both file paths and URIs are supported. For example:
    • File path: /data/user/0/com.compdfkit.flutter.example/cache/temp/PDF_Document.pdf
    • URI: content://media/external/file/1000045118
  • removeSecurity Whether to remove the document's password.
  • fontSubSet Whether to embed the font subset when saving the PDF. This will affect how text appears in other PDF software. This is a time-consuming operation.

Implementation

Future<bool> saveAs(String savePath,
    {bool removeSecurity = false, bool fontSubSet = true}) async {
  try {
    return await _channel.invokeMethod('save_as', {
      'save_path': savePath,
      'remove_security': removeSecurity,
      'font_sub_set': fontSubSet
    });
  } on PlatformException catch (e) {
    debugPrint(e.details);
    return false;
  } catch (e) {
    return false;
  }
}