我使用pdf庫和MultiPage,并且我想重復特定的小部件,以便每個小部件位于單獨的頁面上。我怎么做?
我不想使用addPage,因為我有頁眉、頁腳和某些格式不想在每個添加頁面中重復它。
如何將新頁面添加到MultiPage已經具有相同格式的頁面?
uj5u.com熱心網友回復:
// Create a PDF document.
final doc = pw.Document();
_logo = await rootBundle.loadString('assets/logo.svg');
_bgShape = await rootBundle.loadString('assets/invoice.svg');
=====> first_ Add page to the PDF <=======
doc.addPage(
pw.MultiPage(
pageTheme: _buildTheme(
pageFormat,
await PdfGoogleFonts.robotoRegular(),
await PdfGoogleFonts.robotoBold(),
await PdfGoogleFonts.robotoItalic(),
),
header: _buildHeader,
footer: _buildFooter,
build: (context) => [
//Insert to widget
],
),
);
======> second_ Add page to the PDF <========
doc.addPage(
pw.MultiPage(
pageTheme: _buildTheme(
pageFormat,
await PdfGoogleFonts.robotoRegular(),
await PdfGoogleFonts.robotoBold(),
await PdfGoogleFonts.robotoItalic(),
),
header: _buildHeader,
footer: _buildFooter,
build: (context) => [
//Insert to widget
],
),
);
// Return the PDF file content
return doc.save();
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/513774.html
標籤:扑pdf文档
