How to load a PDF document from asset in Flutter PDF Viewer?
This article explains how to load a PDF document from assets in the Syncfusion® Flutter PDF Viewer.
The Syncfusion® Flutter PDF Viewer widget provides support for loading a PDF document from Asset, Network, File, and Memory. The SfPdfViewer.asset is used to load a PDF document from assets, which creates a widget that displays the PDF document obtained from the provided asset.
The following steps explain how to load a PDF document from assets in the Syncfusion® Flutter PDFViewer:
Step 1: Create Create a new directory in the root directory of the project and name it "assets." Add the PDF document inside the new directory, as shown in the following image.
Step 2: Add the PDF document to the assets section of the pubspec.yaml file.
uses-material-design: true assets: - assets/gis_succinctly.pdf
Step 3: The following code explains how to load a PDF document from assets in the Syncfusion® Flutter PDF Viewer
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Syncfusion Flutter PDF Viewer'), ), body: SfPdfViewer.asset( 'assets/gis_succinctly.pdf', ), ); }
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 Network, File, and Memory to load the PDF document.
Conclusion
I hope you enjoyed learning how to load a PDF document from assets in the Flutter PDF Viewer.
You can refer to our Flutter PDF Viewer feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Viewer example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!