一个 Flutter 插件,可从 HTML 代码模板生成 PDF 文档。它允许开发者直接从 HTML 和 CSS 渲染丰富且样式化的内容,非常适合在 Flutter 应用中创建发票、报告和可打印文档。该插件支持 Android 和 iOS 平台,并能与现有的基于 HTML 的设计无缝集成。它利用原生渲染功能,确保跨设备的高质量输出和一致的格式。
Code above simply generates PDF file from HTML content. It should work with most of common HTML markers. You don’t need to add .pdf extension to targetFileName because plugin only generates PDF files and extension will be added automatically.
Other Usages
You can also pass File object with HTML content inside as parameter
var file = File("/sample_path/example.html");
var generatedPdfFile = awaitFlutterHtmlToPdf.convertFromHtmlFile(
file, targetPath, targetFileName);
or even just path to this file
var filePath = "/sample_path/example.html";
var generatedPdfFile = awaitFlutterHtmlToPdf.convertFromHtmlFilePath(
filePath, targetPath, targetFileName);
Images
If your want to add local image from device to your HTML you need to pass path to image as src value.