0

I have written code for writing content and viewing pdf in flutter

For writing :

     writeOnPdf(){
        pdf.addPage(
         pw.MultiPage(
          pageFormat: PdfPageFormat.a4,
           margin: pw.EdgeInsets.all(32),

     build: (pw.Context context){
      return <pw.Widget>[
        pw.Header(
          level: 0,
          child: pw.Text("Report of the Document")
        ),

        pw.Paragraph(
          text: "Name of the Patient: XYZ"
        ),
        pw.Paragraph(
            text: "Gender of the Patient: M/F"
        ),

        pw.Header(
          level: 1,
          child: pw.Text("Conclusion")
        ),

        pw.Paragraph(
          text: "You need to refer doctor"
        )

      ];

    }
  )
);

}

And for saving pdf:

             Future savePdf() async{
Directory documentDirectory =await getApplicationDocumentsDirectory();

String documentPath = documentDirectory.path;

File file = File("$documentPath/example.pdf");

file.writeAsBytesSync(pdf.save());

}

How can I view saved "example.pdf" in external storage? I have checked the folder of the app in storage but I can't find it. If else how to store to external storage?

1 Answers1

0

in the app folder, there should be a folder called 'app_flutter'. That is where i find the items I write to local storage.

JonnyH
  • 358
  • 2
  • 8