在MultiPage Pdf Flutter中添加新页面



我使用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();

最新更新