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

GitHub 代码仓cloudacy/pdf_image_renderer

pdf_image_renderer

Flutter 插件:使用原生渲染器将 PDF 渲染为位图。

pdf_image_renderer 项目封面
星标
7
复刻
15
最近推送(UTC)
2026年9月18日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

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..."),
          )
        )
    );
  }
}

cloudacy GitHub avatar
GitHub 作者

cloudacy ↗

Tirol, Austria官方网站 ↗
语言DartSwiftKotlinRubyObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 3 项

  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.1.8
  • flutter_lints开发依赖^6.0.0

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗