パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.1

pdf_image_renderer

OSのネイティブレンダラーを使用して、PDFを高速かつ簡単にレンダリングできるパッケージです。

AndroidiOS
30日間ダウンロード
5290
いいね数
36
Pub ポイント
150

パッケージをインストール

flutter pub add pdf_image_renderer

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

pdf_image_renderer パッケージは、Android および iOS のネイティブ PDF レンダリング機能を活用することで、高速かつ簡単な PDF ドキュメントのレンダリングを可能にします。純粋な Dart 実装に依存せずに、PDF ページを画像に変換するための軽量で効率的なソリューションを提供します。このアプローチにより、高いパフォーマンスと正確なビジュアル出力が保証され、ネイティブ OS の動作に非常に近い結果を得られます。PDF の迅速なプレビューまたはサムネイルが必要なアプリケーションに最適であり、最小限の設定で簡単に統合できます。このパッケージは cloudacy.com によってメンテナンスされており、両方の主要なモバイルプラットフォームに対応しています。

用途

  • PDFサムネイルの生成
  • アプリケーションでPDFページをレンダリングする
  • ドキュメントの画像プレビューを作成する
  • 完全なビューアなしでPDFコンテンツを表示する
  • Flutter におけるネイティブ PDF レンダリングの統合

主な機能

  • ネイティブOSのPDFレンダラーを使用
  • 高性能および高精度
  • 最小限のセットアップが必要
  • クロスプラットフォーム対応(Android、iOS)
  • 軽量かつ効率的

適している対象

  • PDFプレビューが必要なモバイルアプリ
  • 画像ベースの文書処理
  • パフォーマンスに敏感なレンダリングアプリ
  • ネイティブレンダリングの正確性を求める開発者
  • 重いPDFライブラリを避けるプロジェクト

注意事項

  • Android および iOS に限定
  • Webまたはデスクトップに対応していません
  • プラットフォーム固有のPDFレンダリングに依存しています
  • デバイスのOSバージョンによってわずかに異なる場合があります
  • インタラクティブなPDF機能をサポートしていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

pdf_image_renderer

pub package

Renders PDFs to bitmaps using native renderers.

Usage

See the example folder for a fully working flutter example.

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Uint8List image;

  void renderPdfImage() async {
    // Get a path from a pdf file (we are using the file_picker package (https://pub.dev/packages/file_picker))
    String path = await FilePicker.getFilePath(type: FileType.custom, allowedExtensions: ['pdf']);

    // Initialize the renderer
    final pdf = PdfImageRenderer(path: path);

    // open the pdf document
    await pdf.open(
      // password: 'password', // optional (iOS and Android 15.0+ support - ignored otherwise)
    )

    // open a page from the pdf document using the page index
    await pdf.openPage(pageIndex: 0);

    // get the render size after the page is loaded
    final size = await pdf.getPageSize(pageIndex: 0);

    // get the actual image of the page
    final img = await pdf.renderPage(
          pageIndex: pageIndex,
          x: 0,
          y: 0,
          width: size.width, // you can pass a custom size here to crop the image
          height: size.height, // you can pass a custom size here to crop the image
          scale: 1, // increase the scale for better quality (e.g. for zooming)
          background: Colors.white,
        );

    // close the page again
    await pdf.closePage(pageIndex: 0);

    // close the PDF after rendering the page
    pdf.close();

    // use setState to update the renderer
    setState(() {
      image = img;
    });
  }

  @override
  void initState() {
    super.initState();
  }


  // you can use this image later in your build function
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('pdf_image_renderer'),
          ),
          body: Center(
            child: image != null ? Image(image: MemoryImage(image)) : Text("Loading..."),
          )
        )
    );
  }
}

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.1.8

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。