How to load Flutter SfPdfViewer from internal storage files?
This article explains how to load a PDF document from the internal storage in the Flutter PDF Viewer.
The Syncfusion® Flutter PDF Viewer widget provides the support to load a PDF document from Asset, Network, File, and Memory. The SfPdfViewer.file is used to load a PDF document from a file.
To load a PDF document from the internal storage in the Syncfusion® Flutter PDFViewer follow these instructions.
Step 1: Add read permission [android\app\src\main\AndroidManifext.xml] in the AndriodManifest.xml file.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Step 2: Mention the PDF file path while creating the SfPdfViewer widget as shown in the following code.
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Syncfusion Flutter PDF Viewer'), ), body: SfPdfViewer.file( File('storage/emulated/0/Download/gis_succinctly.pdf'), ), ); }
Screenshot:
A complete working sample can be downloaded from here.
Take a moment to peruse the documentation for loading PDF documents. You can also find other options like Asset, Network, and Memory to load the PDF document.