Open a Document in Flutter PDF Viewer (SfPdfViewer)

13 Mar 20251 minute to read

The SfPdfViewer widget allows you to open PDF documents from various sources, like local storage, memory or URLs using respective constructors. It also lets you view password-protected documents.

This section walks you through the loading of documents in SfPdfViewer and handling the load-specific events.

Supported constructor types

The SfPdfViewer supports the following constructor types.

  1. Asset
  2. Network
  3. Memory
  4. File

Load the document with the specified page

The SfPdfViewer allows you to load the document with the specified page using the initialPageNumber property. The following code example explains the same.

@override
Widget build(BuildContext context) {
  return Scaffold(
      body: SfPdfViewer.network(
              'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',
              initialPageNumber: 5));
}

NOTE

It is recommended not to use both the initialScrollOffset and initialPageNumber properties at the same time. If both properties are defined, the initialPageNumber will be prioritized over the initialScrollOffset

Load document with the specified scroll offset position or zoom level

The SfPdfViewer allows you to load the document with the specified scroll offset position or zoom level using the initialScrollOffset and initialZoomLevel properties. The following code example explains the same.

@override
Widget build(BuildContext context) {
  return Scaffold(
      body: SfPdfViewer.network(
              'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',
              initialScrollOffset: Offset(0, 500),
              initialZoomLevel: 1.5));
}