【问题标题】:Convert List of encoded Image to PDF将编码图像列表转换为 PDF
【发布时间】:2020-10-21 02:06:28
【问题描述】:

首先,我将PDF 文件转换为Image 文件。

然后我对图像进行更改(转换后的 PDF)。

现在,我想将所有内容都转换回 PDF,并拥有一份 base64 格式的 PDF 副本。

这就是我转换 PDF 的方式:

 Future<List<List<int>>> imageFromPdfFileFullImage(
      Future<PdfDocument> pdfFile) async {
    int height = 0, width = 0;

    final document = await pdfFile;
    im.Image imImage;
    for (int i = 1; i <= document.pagesCount; i++) {
      final page = await document.getPage(i);
      final pdfPageImage = await page.render(
          width: page.width, height: page.height, format: PdfPageFormat.JPEG);
      imImage = im.decodeJpg(pdfPageImage.bytes); // First issue in this line
      height += imImage.height;
      if (imImage.width > width) {
        width = imImage.width;
      }

      //List<Image> buffer 'package:image/image.dart'
      imageList.add(imImage);
      //List<List<int>> 'package:image/image.dart' as im
      //I want this encodeImaegList to be converted back to PDF later
      encodeImageList.add(im.encodePng(imageList[i - 1]));

      await page.close();
    }

    return encodeImageList;
  }

这对于那些希望将某些 pdf 文件转换为图像的人可能很有用。

我希望你也能帮助我解决我的问题。谢谢大家!

【问题讨论】:

    标签: flutter dart flutter-layout flutter-test


    【解决方案1】:

    试试这个包,希望对你有帮助 https://pub.dev/packages/pdf

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-07
      • 2016-09-14
      • 2012-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多