[英]FileSystemException: Cannot open file, path = 'Directory: '/storage/emulated/0/Android/data/
I'm trying to save a pdf on my device , but i got this error我正在尝试在我的设备上保存 pdf,但出现此错误
FileSystemException: Cannot open file, path = 'Directory: '/storage/emulated/0/Android/data/esofos.health/files'/test.pdf
FileSystemException:无法打开文件,路径 = '目录:'/storage/emulated/0/Android/data/esofos.health/files'/test.pdf
this is the function that generate the document这是生成文档的函数
_generatepdf() async {
//Get external storage directory
final directory = await getExternalStorageDirectory();
//Get directory path
final path = directory;
// Create a new PDF document.
final PdfDocument document = PdfDocument();
// Add a PDF page and draw text.
document.pages.add().graphics.drawString(
'Hello World!', PdfStandardFont(PdfFontFamily.helvetica, 12),
brush: PdfSolidBrush(PdfColor(0, 0, 0)),
bounds: const Rect.fromLTWH(0, 0, 150, 20));
// Save the document.
print(path);
File('$path/test.pdf').writeAsBytes(document.save());
// Dispose the document.
document.dispose();
};
When checking the provided code snippet, the directory path was not type casted properly.检查提供的代码片段时,目录路径的类型转换不正确。 We request you to change the below code to save and open the pdf file properly.
我们要求您更改以下代码以正确保存和打开 pdf 文件。
final path = directory!.path;
Please refer to the below documentation link,请参考以下文档链接,
UG: https://help.syncfusion.com/flutter/pdf/getting-started#save-and-open-a-pdf-document-in-mobile UG: https ://help.syncfusion.com/flutter/pdf/getting-started#save-and-open-a-pdf-document-in-mobile
Note: I work for Syncfusion.注意:我为 Syncfusion 工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.