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

插件详情v1.0.7

flutter_plugin_pdf_viewer

一个用于处理 PDF 文件的 Flutter 插件。可在 Android 和 iOS 上运行

近 30 天下载
125
喜欢数
63
Pub 分数
40

安装插件

flutter pub add flutter_plugin_pdf_viewer

插件介绍

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

一个专为移动应用程序设计的 Flutter 插件,用于在 Android 和 iOS 平台上显示和处理 PDF 文件。它提供了一个简单的界面,可在应用 UI 中直接渲染 PDF,使用户无需离开应用即可查看文档。该插件轻量且与 Flutter 的 widget 系统无缝集成,非常适合需要文档查看功能的应用。

适合场景

  • 显示用户生成的PDF
  • 在应用程序内查看文档
  • 显示发票或收据
  • 阅读电子教科书
  • 渲染扫描的文档

主要特点

  • 跨平台支持(Android 和 iOS)
  • 与 Flutter 小部件的简单集成
  • 高效的PDF渲染
  • 支持缩放和滚动
  • 轻便且快速

适合对象

  • 需要PDF显示的移动应用
  • 教育类或电商应用
  • 文档管理工具
  • 内部业务应用
  • 包含数字内容的应用程序

使用建议

  • 不支持 PDF 编辑
  • 仅限查看
  • 无内置搜索功能
  • 某些设备需要外部文件访问权限
  • 性能可能因大型 PDF 而异

原始 README

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

flutter_plugin_pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS

Installation

Add flutter_plugin_pdf_viewer as a dependency in your pubspec.yaml file.

flutter_plugin_pdf_viewer: any

Android

No permissions required. Uses application cache directory.

iOS

No permissions required.

How-to:

Load PDF
// Load from assets
PDFDocument doc = await PDFDocument.fromAsset('assets/test.pdf');
 
// Load from URL
PDFDocument doc = await PDFDocument.fromURL('http://www.africau.edu/images/default/sample.pdf');

// Load from file
File file  = File('...');
PDFDocument doc = await PDFDocument.fromFile(file);
Load pages
// Load specific page
PDFPage pageOne = await doc.get(page: _number);
Pre-built viewer

Use the pre-built PDF Viewer

@override
  Widget build(BuildContext context) {
    Scaffold(
        appBar: AppBar(
          title: Text('Example'),
        ),
        body: Center(
        child: _isLoading
            ? Center(child: CircularProgressIndicator())
            : PDFViewer(document: document)),
    );
  }

This code produces the following view:

Demo Screenshot 1

TODO

  • Allow password-protected files
  • Refactor PDFDocument.getAll() method
  • Increase page resolution
  • Add swipe to change page

Third-party packages used
Name Description
path_provider A Flutter plugin for finding commonly used locations on the filesystem. Supports iOS and Android.
flutter_cache_manager A CacheManager to download and cache files in the cache directory of the app. Various settings on how long to keep a file can be changed.
numberpicker NumberPicker is a custom widget designed for choosing an integer or decimal number by scrolling spinners.
flutter_advanced_networkimage An advanced image provider provides caching and retrying for flutter app. Now with zoomable widget and transition to image widget.

所属分类

依赖

依赖清单 5 项

源码仓库

使用此插件的项目

暂无相关数据。