Flutter -PDF-错误-此小部件创建了20多个页面.这可能是小部件或文档中的问题 [英] Flutter -PDF -- Error - This widget created more than 20 pages. This may be an issue in the widget or the document
问题描述
我正在创建内容丰富的PDF文档.但是,我无法显示PDF并出现错误
I am creating a PDF document that has a large content. However, I am not able to show the PDF and I get the error
此小部件创建了20多个页面.这可能是小部件或文档中的问题."
"This widget created more than 20 pages. This may be an issue in the widget or the document."
我知道文本太大,但是我不知道如何使它起作用
I know the text is too large but I don't know how to make it work
pdf.addPage(
pw.MultiPage(
pageFormat: PdfPageFormat.a4,
orientation: pw.PageOrientation.portrait,
crossAxisAlignment: pw.CrossAxisAlignment.start,
build: (pw.Context context) {
return <pw.Widget>[
pw.Wrap(
children: <pw.Widget>[
pw.Container(
width: PdfPageFormat.a4.width,
child: pw.Row(
mainAxisSize: pw.MainAxisSize.min,
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Expanded(
child: pw.Column(
mainAxisSize: pw.MainAxisSize.min,
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.SizedBox(height: 8.0),
for (int i = 0; i < data['employers'].length; i++)
pw.Column(
mainAxisSize: pw.MainAxisSize.min,
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Text(
"${data['employers'][i]['duties']}",
style: pw.TextStyle(
fontSize: 12.0,
),
softWrap: true,
),
],
),
],
),
),
],
),
),
],
),
];
},
),
);
我需要一些有关如何重组代码的帮助,以便可以显示PDF并将其包装到下一页文本只是一组Lorem Ipsum.
I need some help on how to restructure my code so that I can display the PDF and have it wrap to the next page The text is just a a set of Lorem Ipsum .
感谢您的帮助
推荐答案
此可能是您的问题的解决方案
This might be a solution for your question
我粘贴了链接的代码,以防您无法输入.
I paste the link's code in case you can't enter it.
假设我们有一个列表问题
:
pdf.addPage(
MultiPage(
build: (Context context) => <Widget>[
Wrap(
children: List<Widget>.generate(issues.length, (int index) {
final issue = issues[index];
return Container(
child: Column(
children: <Widget>[
Header(
text: "Issue n°${issue.id}",
textStyle: TextStyle(fontSize: 20)),
Text("Description :",
textAlign: TextAlign.left,
style: TextStyle(fontSize: 15)),
],
),
);
}),
),
],
),
);
这篇关于Flutter -PDF-错误-此小部件创建了20多个页面.这可能是小部件或文档中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!