SfPdfViewer class Null safety

A widget to view PDF documents.

SfPdfViewer lets you display the PDF document seamlessly and efficiently. It is built in the way that a large PDF document can be opened in minimal time and all their pages can be accessed spontaneously.

SfPdfViewer provides option to navigate to the desired pages and bookmarks within the document. Also it allows zooming and customization of features being displayed, such as scroll head, page scroll status and navigation dialog.

This example demonstrates how to load the PDF document from AssetBundle.

class MyAppState extends State<MyApp>{
@override
void initState() {
  super.initState();
}

@override
Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SfPdfViewer.asset(
          'assets/flutter-succinctly.pdf',
        ),
      ),
    );
  }
}
Inheritance
Annotations

Constructors

SfPdfViewer.asset(String name, {Key? key, AssetBundle? bundle, bool canShowScrollHead = true, double pageSpacing = 4, PdfViewerController? controller, PdfZoomLevelChangedCallback? onZoomLevelChanged, bool canShowScrollStatus = true, PdfPageChangedCallback? onPageChanged, PdfDocumentLoadedCallback? onDocumentLoaded, bool enableDoubleTapZooming = true, bool enableTextSelection = true, PdfTextSelectionChangedCallback? onTextSelectionChanged, PdfDocumentLoadFailedCallback? onDocumentLoadFailed, bool enableDocumentLinkAnnotation = true, bool canShowPaginationDialog = true, Offset initialScrollOffset = Offset.zero, double initialZoomLevel = 1, PdfInteractionMode interactionMode = PdfInteractionMode.selection, PdfScrollDirection scrollDirection = PdfScrollDirection.vertical, PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous, Color searchTextHighlightColor = const Color(0xFFE56E00)})
Creates a widget that displays the PDF document obtained from an asset bundle. [...]
SfPdfViewer.file(File file, {Key? key, bool canShowScrollHead = true, double pageSpacing = 4, PdfViewerController? controller, PdfZoomLevelChangedCallback? onZoomLevelChanged, bool canShowScrollStatus = true, PdfPageChangedCallback? onPageChanged, bool enableDoubleTapZooming = true, bool enableTextSelection = true, PdfTextSelectionChangedCallback? onTextSelectionChanged, PdfDocumentLoadedCallback? onDocumentLoaded, PdfDocumentLoadFailedCallback? onDocumentLoadFailed, bool enableDocumentLinkAnnotation = true, bool canShowPaginationDialog = true, Offset initialScrollOffset = Offset.zero, double initialZoomLevel = 1, PdfInteractionMode interactionMode = PdfInteractionMode.selection, PdfScrollDirection scrollDirection = PdfScrollDirection.vertical, PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous, Color searchTextHighlightColor = const Color(0xFFE56E00)})
Creates a widget that displays the PDF document obtained from File. [...]
SfPdfViewer.memory(Uint8List bytes, {Key? key, bool canShowScrollHead = true, double pageSpacing = 4, PdfViewerController? controller, PdfZoomLevelChangedCallback? onZoomLevelChanged, bool canShowScrollStatus = true, PdfPageChangedCallback? onPageChanged, bool enableDoubleTapZooming = true, bool enableTextSelection = true, PdfTextSelectionChangedCallback? onTextSelectionChanged, PdfDocumentLoadedCallback? onDocumentLoaded, PdfDocumentLoadFailedCallback? onDocumentLoadFailed, bool enableDocumentLinkAnnotation = true, bool canShowPaginationDialog = true, Offset initialScrollOffset = Offset.zero, double initialZoomLevel = 1, PdfInteractionMode interactionMode = PdfInteractionMode.selection, PdfScrollDirection scrollDirection = PdfScrollDirection.vertical, PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous, Color searchTextHighlightColor = const Color(0xFFE56E00)})
Creates a widget that displays the PDF document obtained from Uint8List. [...]
SfPdfViewer.network(String src, {Key? key, Map<String, String>? headers, bool canShowScrollHead = true, double pageSpacing = 4, PdfViewerController? controller, PdfZoomLevelChangedCallback? onZoomLevelChanged, bool canShowScrollStatus = true, PdfPageChangedCallback? onPageChanged, bool enableDoubleTapZooming = true, bool enableTextSelection = true, PdfTextSelectionChangedCallback? onTextSelectionChanged, PdfDocumentLoadedCallback? onDocumentLoaded, PdfDocumentLoadFailedCallback? onDocumentLoadFailed, bool enableDocumentLinkAnnotation = true, bool canShowPaginationDialog = true, Offset initialScrollOffset = Offset.zero, double initialZoomLevel = 1, PdfInteractionMode interactionMode = PdfInteractionMode.selection, PdfScrollDirection scrollDirection = PdfScrollDirection.vertical, PdfPageLayoutMode pageLayoutMode = PdfPageLayoutMode.continuous, Color searchTextHighlightColor = const Color(0xFFE56E00)})
Creates a widget that displays the PDF document obtained from the network. [...]

Properties

canShowPaginationDialog bool
Indicates whether the page navigation dialog can be shown when the scroll head is tapped. [...]
final
canShowScrollHead bool
Indicates whether the scroll head in SfPdfViewer can be displayed or not. [...]
final
canShowScrollStatus bool
Indicates whether the page scroll status in SfPdfViewer can be displayed or not. [...]
final
controller PdfViewerController?
An object that is used to control the navigation and zooming operations in the SfPdfViewer. [...]
final
enableDocumentLinkAnnotation bool
Indicates whether the document link annotation navigation can be performed or not. [...]
final
enableDoubleTapZooming bool
Indicates whether the double tap zooming in SfPdfViewer can be allowed or not. [...]
final
enableTextSelection bool
Indicates whether the text selection can be performed or not. [...]
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
initialScrollOffset Offset
Represents the initial scroll offset position to be displayed when the SfPdfViewer widget is loaded. [...]
final
initialZoomLevel double
Represents the initial zoom level to be applied when the SfPdfViewer widget is loaded. [...]
final
interactionMode PdfInteractionMode
Indicates the interaction modes of SfPdfViewer in a desktop browser. [...]
final
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
onDocumentLoaded PdfDocumentLoadedCallback?
Called after the document is loaded in SfPdfViewer. [...]
final
onDocumentLoadFailed PdfDocumentLoadFailedCallback?
Called when the document loading fails in SfPdfViewer. [...]
final
onPageChanged PdfPageChangedCallback?
Called when the page changes in SfPdfViewer. [...]
final
onTextSelectionChanged PdfTextSelectionChangedCallback?
Called when the text is selected or deselected in SfPdfViewer. [...]
final
onZoomLevelChanged PdfZoomLevelChangedCallback?
Called when the zoom level changes in SfPdfViewer. [...]
final
pageLayoutMode PdfPageLayoutMode
The layout mode in which the PDF page will be rendered. [...]
final
pageSpacing double
Represents the spacing (in pixels) between the PDF pages. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
scrollDirection PdfScrollDirection
The direction in which the PDF page scrolls. [...]
final
searchTextHighlightColor Color
The text search highlight color to be displayed on the instances found. [...]
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() SfPdfViewerState
Creates the mutable state for this widget at a given location in the tree. [...]
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object. [...]
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited