搜尋套件、儲存庫與 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

原始碼儲存庫

使用此套件的專案

暫無相關資料。