FLUTTER ECOSYSTEM

erluxman/pdf_flutter

用於顯示PDF的Flutter小部件

pdf_flutter 專案封面
Stars
98
Forks
50
最近推送(UTC)
2022年10月12日
專案狀態
未封存
Laxman Bhattarai GitHub avatar
GITHUB User

Laxman Bhattarai ↗

Android & Flutter Developer. Freelancer

FreelancerKathmandu Nepal官方網站 ↗
語言DartObjective-CRubyJava

此儲存庫發佈的套件

使用的依賴

依賴清單 6 項

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

pdf_flutter

pub package

Inspired by Pdf_Viewer_Plugin 😇 Wrapped around AndroidPdfViewer on Android. 🙏🏼

1. Add pdf_flutteron pubspec.yml
dependencies:
  pdf_flutter: ^version
2. On iOS enable PDF preview like this:

Add this on ios/Runner/info.plist:

    <key>io.flutter.embedded_views_preview</key>
    <true/>
3. Start Using
Load PDF from network (caches PDF from network)
    PDF.network(
            'https://raw.githubusercontent.com/FlutterInThai/Dart-for-Flutter-Sheet-cheet/master/Dart-for-Flutter-Cheat-Sheet.pdf',
            height: 500,
            width: 300,
            maxAndroidZoom: widget.maxAndroidZoom,
            midAndroidZoom: widget.midAndroidZoom,
            minAndroidZoom: widget.minAndroidZoom,
    )
Load PDF files
    File fileName;  
    PDF.file(
        fileName,
        height: 200,
        width: 100,
        maxAndroidZoom: widget.maxAndroidZoom,
        midAndroidZoom: widget.midAndroidZoom,
        minAndroidZoom: widget.minAndroidZoom,
    )
Load PDF from assets
    PDF.assets(
        "assets/pdf/demo.pdf",
        height: 200,
        width: 100,
        maxAndroidZoom: widget.maxAndroidZoom,
        midAndroidZoom: widget.midAndroidZoom,
        minAndroidZoom: widget.minAndroidZoom,
    )
For Production
Here are the steps to fix:
    1. Add proguard-rules.pro file if its not already there
https://user-images.githubusercontent.com/2768159/91779534-e288fd00-ebc3-11ea-9c6f-d3e3a9d0922c.png
    2. Inside of the proguard-rules.pro file put this:
        -keep class com.shockwave.**
        -keepclassmembers class com.shockwave.** { *; }
        
    3.In app/build.gradle add this:
https://user-images.githubusercontent.com/2768159/91779653-37c50e80-ebc4-11ea-8fbb-22d5c8e5a9ed.png
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

Demo

demo