一個 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.