【发布时间】:2022-10-05 16:53:37
【问题描述】:
我使用pdf 库和MultiPage,我想重复特定的小部件,以便每个小部件位于单独的页面上。我怎么做?
我不想使用addPage,因为我有页眉、页脚和某些格式不想在每个添加页面中重复它。
如何将新页面添加到已经具有相同格式的MultiPage?
我使用pdf 库和MultiPage,我想重复特定的小部件,以便每个小部件位于单独的页面上。我怎么做?
我不想使用addPage,因为我有页眉、页脚和某些格式不想在每个添加页面中重复它。
如何将新页面添加到已经具有相同格式的MultiPage?
// 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();
【讨论】: