Home > database >  Flutter pdf packe fullfill all the a4 format?
Flutter pdf packe fullfill all the a4 format?

Time:12-23

I am using flutter pdf plugin.This is my code:

pdf.addPage(pw.Page(
          pageFormat: PdfPageFormat.a4,
          build: (pw.Context contex) {
            return  pw.Image(image,fit:pw.BoxFit.fill);//pw.Container(


                //child:
                    //pw.Image(image,fit:pw.BoxFit.fill));
          }));

The problem is that I want to make pictures fulfill all pdf pages.

but it looks like this:

enter image description here

There are spaces around the edges.

CodePudding user response:

I used FullPage and it worked.

 pdf.addPage(pw.Page(
              pageFormat: PdfPageFormat.a4,
              build: (pw.Context contex) {
                return pw.FullPage(
                    ignoreMargins: true,
                    child: pw.Image(image,fit: pw.BoxFit.fill),
                  );
                //pw.Container(
    
    
                    //child:
                        //pw.Image(image,fit:pw.BoxFit.fill));
              }));

CodePudding user response:

you could try using center :

pdf.addPage(pw.Page(
      pageFormat: PdfPageFormat.a4,
      build: (pw.Context context) {
        return pw.Center(
          child: pw.Image(image),
          );  // Center
      })); // Page

If not, you can use FittedBox along withit:

FittedBox(
  child: pw.Image(image),
  fit: BoxFit.fill,
)

More details on: here

  • Related