Table of contents
No headings in the article.
Hello, everyone here is my first article i will writing about Flutter, so I think there is room for corrections so I can improve more.
So I was working on a project and it involves having a PDF file on the app so the user can be able to use access and do exactly what you will do a PDF viewer application.
I reach to a Flutter community but got no response, then I made some researches on my own and came across a Flutter package "Syncfusion PDF Viewer" pub.dev/packages/syncfusion_flutter_pdfviewer".
He is my work through how to use it.
Run this command
flutter pub add syncfusion_flutter_pdfviewer
The above command will add a line like this to your package's pubspec.yaml.
dependencies:
syncfusion_flutter_pdfviewer: ^19.2.62-beta
Then you can import it to your dart file.
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
Some of the functionality that can be implemented using the package includes:
- PDF sources
- Scrolling
- Magnification
- Link Annotation
- Text Selection
- Text Search
- Page Navigation
- Bookmark Navigation
- Appearance
- Localization
PDF Sources
PDF can be loaded through various sources which includes AssetBundle, Network or URL, memory and file.
For AssetBundle
SfPdfViewer.asset("assets/pdf/mypdf.pdf"),
For network
SfPdfViewer.network(
'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',
),
Scrolling
You can either scroll horizontally or vertically.
scrollDirection: PdfScrollDirection.horizontal