【问题标题】:Add New Page in MultiPage Pdf Flutter在 MultiPage Pdf Flutter 中添加新页面
【发布时间】:2022-10-05 16:53:37
【问题描述】:

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

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

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

    标签: flutter pdf document


    【解决方案1】:
    // 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();
    

    【讨论】:

      猜你喜欢
      • 2014-06-05
      • 2021-05-20
      • 2014-05-09
      • 2017-04-13
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 1970-01-01
      相关资源
      最近更新 更多