How to break page when generating PDF from flutter PDF package
930
you could just use two multipages like that:
pdf.addPage(pw.MultiPage(
pageFormat: PdfPageFormat.a4,
build: (pw.Context context) {
return pw.Center(
child:Column(
children:[
pw.Text("Hello World"),
]
)
); // Center
}));
pdf.addPage(pw.MultiPage(
pageFormat: PdfPageFormat.a4,
build: (pw.Context context) {
return pw.Center(
child:Column(
children:[
pw.Text("Hello 2"),
]
)
); // Center
}));
Author by
s.am.i
Updated on December 27, 2022Comments
-
s.am.i over 1 year
I am trying to generate a pdf using flutter pdf package pdf ,Everything works fine but I want to generate sections on multiple pages below I added sample of my code
final pdf = pw.Document();
pdf.addPage(pw.MultiPage( pageFormat: PdfPageFormat.a4, build: (pw.Context context) { return pw.Center( child:Column( children:[ pw.Text("Hello World"), pw.Text("Hello 2"), ] ) ); // Center }));
How to get Hello World on 1st page and Hello 2 on second page ?
-
s.am.i about 3 yearsIf i use like that when saving document is it coming as single pdf
-
Freddy Straub about 3 yearsSure one single pdf. Do you want multiple pdf files?
-
s.am.i about 3 yearsNo I need it as one.your answer was helpful