无法将参数类型“PdfImage”分配给参数类型“ImageProvider”

时间:2021-07-12 19:36:54

标签: flutter dart

我正在尝试将屏幕截图图像转换为 pdf 然后保存...但卡在转换步骤

  Future getPdf(Uint8List screenShot) async {

    pw.Document pdf = pw.Document();

    pdf.addPage(
      pw.Page(
        pageFormat: PdfPageFormat.a4,
        build: (context) {
          return pw.Expanded(
              child: pw.Image(PdfImage.file((pdf.document), bytes:screenShot),fit: pw.BoxFit.contain);
          );
        },
      ),
    );
    File pdfFile = File('Your path + File name');
    pdfFile.writeAsBytesSync(pdf.save());
  }
}

0 个答案:

没有答案
相关问题