Pub Version codecov GitHub branch checks state

With this widget, you can display a PDF with bytes or a path.



This package is forked from flutter_pdfview (Link) of endigo and rebuilt from scratch.

The package alh_pdf_view also includes:

  • Displays also PDF with bytes
  • FitPolicy for iOS and Android
  • some blurriness fixes on Android side
  • some more functionalities
  • Rotation works on iOS and Android
  • Tests for the whole written code on Dart



  • implemented in Swift with the dependency PDFKit


import 'package:alh_pdf_view/lib.dart';
import 'package:flutter/material.dart';

class AlhPdfViewExample extends StatelessWidget {
  const AlhPdfViewExample({Key? key}) : super(key: key);

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('PDF Example')),
      body: const AlhPdfView(
        filePath: 'ADD_PATH_TO_FILE',


This is a list of all parameters that can be used for this widget. Consider that some paremters only work for one platform.

ParameterDescriptionDefault Value
filePathOptional path to load PDF file.-
bytesOptional bytes to load PDF file.-
fitPolicyDefines how the PDF should fit inside the widget.FitPolicy.both
fitEachPageEach page of the PDF will fit inside the given space.true
enableSwipeThe current page will be changed when swiping.true
swipeHorizontalIf true, all pages are displayed in horizontal direction.false
nightModeInverting colors of pages to have the look of a dark mode. (only Android)false
autoSpacingIf true, spacing will be added to fit each page on its own on the screen. (only Android)true
pageFlingMaking a fling change.true
pageSnapSnap pages to screen boundaries when changing the current page. (only Android)true
defaultPageDescribes which page should be shown at first.0
defaultZoomFactorDefines how much the displayed PDF page should zoomed when rendered.1.0
backgroundColorSetting backgroundColor of remaining space around the pdf view.Colors.transparent
passwordUnlocks PDF page with this password.""
enableDoubleTapWhen double tapping, the zoom of the page changes. (only Android)1.0
minZoomMin zoom value that the user can reach while zooming.0.5
maxZoomMax zoom value that the user can reach while zooming.4.0
enableDefaultScrollHandleAdds a button to scroll faster through the document. (only Android)false

This is a list of functional parameters.

ParameterDescriptionDefault Value
gestureRecognizersWhich gestures should be consumed by the pdf view.-
onViewCreatedIf not null invoked once the native view is created.-
onRenderCallback once the PDF page was loaded.-
onPageChangedWhen changing the page, this method will be called with the new page.-
onZoomChangedCalled when changing the zoom.-
onErrorWhen there are errors happening, this methods returns a message.-
onPageErrorCalled when there are specific errors on a page. (only Android)-


If you want to start specific actions for the displayed PDF file, you can use AlhPdfViewController. This controller contains some functionalities to update your view. Here is a list of them.

getPageSizeReturns the size of the given page index. (only iOS)
getPageCountReturns the number of pages for the PDF.
getCurrentPageReturns the current displayed page.
goToNextPageNavigates to the next page of the PDF.
goToPreviousPageNavigates to the previous page of the PDF.
setPageJumping to the page optionally animated.
resetZoomSetting the scale factor to the default zoom factor.
setZoomZooming to the given zoom.
getZoomReturns the current zoom value.