搜尋套件、儲存庫與 APP 分類

pdf_thumbnail 封面
套件詳情v0.1.6+1

pdf_thumbnail

PDF 檔案的縮圖檢視器。支援 Android 與 iOS。只要加入組件並提供檔案路徑即可。

AndroidiOSWebmacOSWindows
近 30 天下載
3
喜歡數
51
Pub 分數
150

安裝套件

flutter pub add pdf_thumbnail

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個用於在 Android、iOS、Web、macOS 和 Windows 上顯示 PDF 缩略圖的 Flutter 套件。該套件透過簡單地新增一個組件並提供檔案路徑,讓開發者能輕鬆將縮略圖檢視器整合至其應用程式中。此套件輕量且設計為無縫呈現 PDF 頁面預覽,無需複雜設定。非常適合文件管理應用程式或任何需要快速視覺存取 PDF 內容的應用程式。

適用情境

  • 行動應用程式中的文件預覽
  • PDF畫廊介面
  • 快速文件瀏覽
  • 電子學習平台
  • 數位圖書館應用

主要特色

  • 跨平台支援
  • 簡單小工具整合
  • 檔案路徑輸入
  • 輕量級渲染
  • 響應式縮圖佈局

適合對象

  • 開發文件檢視器的開發者
  • 需要 PDF 導航的應用程式
  • 教育或企業軟體
  • 以使用者介面為重點的PDF應用程式

使用建議

  • 需要有效的PDF檔案路徑
  • 僅限縮圖顯示
  • 無互動式PDF功能
  • 未針對大PDF檔案進行優化
  • 取決於底層平台的渲染

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pdf Thumbnail

style: very good analysis Powered by Mason License: MIT

Thumbnail viewer for pdfs

Installation 💻

❗ In order to start using Pdf Thumbnail you must have the Flutter SDK installed on your machine.

Add pdf_thumbnail to your pubspec.yaml:

dependencies:
  pdf_thumbnail:

Install it:

flutter packages get

Example ✍️

 return Stack(
              children: [
                SizedBox(
                  height: MediaQuery.of(context).size.height,
                  width: MediaQuery.of(context).size.width,
                  child: PdfViewer(
                    filePath: snapshot.data!.path,
                  ),
                ),
                if (showThumbnail)
                  Positioned(
                    bottom: 0,
                    width: MediaQuery.of(context).size.width,
                    // Here's the thumbnail widget.
                    child: PdfThumbnail.fromFile(snapshot.data!.path),
                  ),
              ],
            );

There is a detailed example app in the repo, but I've deleted iOS and Android folders. Simple go to example folder, and run flutter create . inside the folder to add missing native files for the example app.

Demo

gif

Caching ⏲

I left caching part unopinionated to keep the package simple. Just create your own class from ImageThumbnailCacher and implement the read/write methods. Holding images as Uint8List, so Map<int, Uint8List> is what's need to be written to and read from the cache. It maps page numbers to the images.

class ThumbnailCacher implements ImageThumbnailCacher {
  @override
  Future<PageToImage?> read(String id) async {
    return api.localStorage.readThumbnails(id);
  }

  @override
  Future<bool> write({required String id, required PageToImage map}) {
    return api.localStorage.writeThumbnails(id: id, map: map);
  }
}

I'm using Hive to cache.

Roadmap 🗺️

  • [X] Customization for colors, decoration etc.
  • [X] onTap callback and page number.
  • [X] Caching.
  • [ ] Different layouts and scroll axises.
  • [ ] Lazy loading.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。