搜索插件、代码仓与 APP 分类

插件详情v2.4.0

alh_pdf_view

具有显示PDF的功能,通过文件路径的字节作为小部件,并带有一些额外功能。

AndroidiOS
近 30 天下载
1440
喜欢数
36
Pub 分数
160

安装插件

flutter pub add alh_pdf_view

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

alh_pdf_view 是一个 Flutter 包,可使用字节数据或文件路径将 PDF 文件显示为小部件。它提供缩放、滚动和页面导航等附加功能,适用于需要交互式 PDF 渲染的应用程序。该包支持 Android 和 iOS 平台,确保跨平台兼容性。它与 Flutter 的小部件系统无缝集成,非常适合在移动应用程序中进行文档查看。

适合场景

  • 从文件路径显示 PDF
  • 从字节数据渲染PDF
  • 带有缩放功能的交互式PDF浏览
  • 在移动应用中嵌入文档
  • 查看用户上传的PDF文件
  • 创建文档预览屏幕

主要特点

  • 支持从字节或文件路径渲染PDF
  • 内置缩放和滚动功能
  • 跨平台(Android 和 iOS)
  • 与 Flutter 小部件轻松集成
  • 轻量且快速的渲染
  • 页面导航控件

适合对象

  • 文档查看器应用
  • 电子学习平台
  • 手机银行应用
  • PDF注释工具
  • 内容管理系统
  • 用户生成内容预览

使用建议

  • 需要正确的文件路径处理
  • 仅限基本的PDF操作
  • 无内置文本选择或搜索
  • 依赖外部原生库
  • 大型 PDF 文件可能存在性能问题
  • 不适用于复杂的PDF编辑

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Pub Version GitHub branch checks state

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

Index

Introduction

The package alh_pdf_view includes:

  • Displays PDF with bytes or path

See more about the functionalities in the parameter section.

Android
iOS
  • implemented in Swift with the dependency PDFKit

Example


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

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

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

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

Parameter Description Default Value
filePath Optional path to load PDF file. -
bytes Optional bytes to load PDF file. -
fitPolicy Defines how the PDF should fit inside the widget. FitPolicy.both
fitEachPage Each page of the PDF will fit inside the given space. (only Android) true
enableSwipe The current page will be changed when swiping. true
swipeHorizontal If true, all pages are displayed in horizontal direction. false
nightMode Inverting colors of pages to have the look of a dark mode. (only Android) false
autoSpacing If true, spacing will be added to fit each page on its own on the screen. (only Android) true
pageFling Making a fling change. true
pageSnap Snap pages to screen boundaries when changing the current page. (only Android) true
defaultPage Describes which page should be shown at first. 0
defaultZoomFactor Defines how much the displayed PDF page should zoomed when rendered. 1.0
backgroundColor Setting backgroundColor of remaining space around the pdf view. Colors.transparent
password Unlocks PDF page with this password. ""
enableDoubleTap When double tapping, the zoom of the page changes. (only Android) 1.0
minZoom Min zoom value that the user can reach while zooming. 0.5
maxZoom Max zoom value that the user can reach while zooming. 4.0
enableDefaultScrollHandle Adds a button to scroll faster through the document. (only Android) false
showScrollbar If true, a Scrollbar is visible for the Pdf View (only iOS). true
spacing Spacing between pdf pages. 0

This is a list of functional parameters.

Parameter Description Default Value
gestureRecognizers Which gestures should be consumed by the pdf view. -
onViewCreated If not null invoked once the native view is created. -
onRender Callback once the PDF page was loaded. -
onPageChanged When changing the page, this method will be called with the new page. -
onZoomChanged Called when changing the zoom. -
onError When there are errors happening, this methods returns a message. -
onLinkHandle Called when tapping a link in PDF. (only iOS) -
AlhPdfViewController

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.

Parameter Description
getPageSize Returns the size of the given [page] index. (only iOS)
getPageCount Returns the number of pages for the PDF.
getCurrentPage Returns the current displayed page.
goToNextPage Navigates to the next page of the PDF.
goToPreviousPage Navigates to the previous page of the PDF.
setPage Jumping to the page optionally animated.
resetZoom Setting the scale factor to the default zoom factor.
setZoom Zooming to the given zoom.
getZoom Returns the current zoom value.

所属分类

依赖

依赖清单 3 项

  • alh_pdf_view_android^2.3.3
  • alh_pdf_view_ios^2.4.0
  • alh_pdf_view_platform_interface^2.3.1

源码仓库

使用此插件的项目

暂无相关数据。