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 the support to load 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 a new directory in the root directory of the project and name it as "assets”. Added the PDF document inside the new directory as shown in the following image.
Step 2: Add the PDF document in the assets section of pubspec.yaml file.
uses-material-design: true assets: - assets/gis_succinctly.pdf
Step 3: The following code explains load a PDF document from assets in the Syncfusion® Flutter PDFViewer.
@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 asset in Flutter PDF Viewer.
You can refer to our Flutter PDF Viewer feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Flatter 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, Direct-Trac, or feedback portal. We are always happy to assist you!