首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在MultiPage Pdf页面中添加新页面

在MultiPage Pdf页面中添加新页面
EN

Stack Overflow用户
提问于 2022-10-03 06:24:51
回答 1查看 121关注 0票数 0

我使用pdf库和MultiPage,并且希望重复特定的小部件,以便每个小部件位于一个单独的页面上。我该怎么做?

我不想使用addPage,因为我有一个页眉、页脚和一些格式不想在每个添加页面中重复它。

如何将新页面添加到已经具有相同格式的MultiPage中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-05 08:53:37

代码语言:javascript
复制
// 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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73931771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档