我想将用相机拍摄的照片插入到pdf表格的单元格中。但我收到以下错误代码

发布于 2025-01-14 03:21:44 字数 2556 浏览 5 评论 0原文

// 我想将相机拍摄的照片插入到pdf表格的单元格中。但我收到以下错误代码。

Reloaded 1 of 1223 libraries in 6.711ms.
E/flutter (21256): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Unable to load asset: File: '/data/user/0/com.example.syncsqftomysql/cache/a7844dd4-e07d-4e16-bdb0-c6618dde63eb-972127577.jpg'
E/flutter (21256): #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:224:7)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): #1      _QrCodeState._readImageDatatoPDF (package:upmp/bysuygformu.dart:1665:18)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): #2      _QrCodeState._createPDF (package:upmp/bysuygformu.dart:1714:15)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): 

//Some of my codes are as follows. An example application may also be useful to //me.

Future<Uint8List> _readImageDatatoPDF(String name) async {
    final data = await rootBundle.load(imageFile.toString());
    return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
  }

Future<void> _createPDF() async {
     PdfDocument document = PdfDocument();
    final page = document.pages.add();
    PdfGrid grid = PdfGrid();
    grid.style = PdfGridStyle(
        font: PdfStandardFont(PdfFontFamily.helvetica, 30),
        cellPadding: PdfPaddings(left: 5, right: 2, top: 2, bottom: 2));
    grid.columns.add(count: 3);
    grid.headers.add(1);
    PdfGridRow header = grid.headers[0];
    header.cells[0].value = '0';
    header.cells[1].value = 'Firma Adresi';
    header.cells[2].value = 'aaa';

    PdfGridRow row = grid.rows.add();
    row.cells[0].value = '1';
    row.cells[1].value = 'Depolar';
    row.cells[2].value = 'K-Ortrine';

    row = grid.rows.add();
    row.cells[0].value = '2';
    row.cells[1].value = 'Merkez';
    row.cells[2].value = 'Icon';

    row = grid.rows.add();`enter code here`
    row.cells[0].value = '3';
    row.cells[1].value = 'Taha';
      PdfGridCell cell2 = row.cells[2];
     grid.rows[2].height = 200;
     cell2.imagePosition = PdfGridImagePosition.stretch;

    cell2.style.backgroundImage =
     
    PdfBitmap(await _readImageDatatoPDF(
      pic.toString()));
     Rect.fromLTWH(0, 0, 0, 0);
       grid.draw(page: page, bounds: const Rect.fromLTWH(0, 0, 0, 0));

    List<int> bytes = document.save();
       document.dispose();`enter code here`
    saveAndLaunchFile(bytes, 'cikti.pdf');
  }

我想将从相机拍摄的照片插入 pdf 表格的单元格中。 我想将从相机拍摄的照片插入 pdf 表格的单元格中。 我想将从相机拍摄的照片插入 pdf 表格的单元格中。

// I want to insert the photo taken with the camera into a cell of the table in the pdf. But I am getting the following error code.

Reloaded 1 of 1223 libraries in 6.711ms.
E/flutter (21256): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Unable to load asset: File: '/data/user/0/com.example.syncsqftomysql/cache/a7844dd4-e07d-4e16-bdb0-c6618dde63eb-972127577.jpg'
E/flutter (21256): #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:224:7)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): #1      _QrCodeState._readImageDatatoPDF (package:upmp/bysuygformu.dart:1665:18)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): #2      _QrCodeState._createPDF (package:upmp/bysuygformu.dart:1714:15)
E/flutter (21256): <asynchronous suspension>
E/flutter (21256): 

//Some of my codes are as follows. An example application may also be useful to //me.

Future<Uint8List> _readImageDatatoPDF(String name) async {
    final data = await rootBundle.load(imageFile.toString());
    return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
  }

Future<void> _createPDF() async {
     PdfDocument document = PdfDocument();
    final page = document.pages.add();
    PdfGrid grid = PdfGrid();
    grid.style = PdfGridStyle(
        font: PdfStandardFont(PdfFontFamily.helvetica, 30),
        cellPadding: PdfPaddings(left: 5, right: 2, top: 2, bottom: 2));
    grid.columns.add(count: 3);
    grid.headers.add(1);
    PdfGridRow header = grid.headers[0];
    header.cells[0].value = '0';
    header.cells[1].value = 'Firma Adresi';
    header.cells[2].value = 'aaa';

    PdfGridRow row = grid.rows.add();
    row.cells[0].value = '1';
    row.cells[1].value = 'Depolar';
    row.cells[2].value = 'K-Ortrine';

    row = grid.rows.add();
    row.cells[0].value = '2';
    row.cells[1].value = 'Merkez';
    row.cells[2].value = 'Icon';

    row = grid.rows.add();`enter code here`
    row.cells[0].value = '3';
    row.cells[1].value = 'Taha';
      PdfGridCell cell2 = row.cells[2];
     grid.rows[2].height = 200;
     cell2.imagePosition = PdfGridImagePosition.stretch;

    cell2.style.backgroundImage =
     
    PdfBitmap(await _readImageDatatoPDF(
      pic.toString()));
     Rect.fromLTWH(0, 0, 0, 0);
       grid.draw(page: page, bounds: const Rect.fromLTWH(0, 0, 0, 0));

    List<int> bytes = document.save();
       document.dispose();`enter code here`
    saveAndLaunchFile(bytes, 'cikti.pdf');
  }

I want to insert the photo I took from the camera into a cell of the table in the pdf.
I want to insert the photo I took from the camera into a cell of the table in the pdf.
I want to insert the photo I took from the camera into a cell of the table in the pdf.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轮廓§ 2025-01-21 03:21:44
cell2.style.backgroundImage =

这就是我要开始的地方。您没有将照片用作对象。您已选择使用图像作为样式。该样式需要调用存储位置而不是将照片视为对象。

  • 例子。我画了墙。错误油漆罐在哪里。
  • 例子。我把油漆罐放在小房间的洞里。查看/显示油漆
    能。
cell2.style.backgroundImage =

This is where I would start. You are not using the photo as an object. You have chosen to use the image as a style. The style would require calling the storage location vs treating the photo as an object.

  • Example. I painted the wall. Error where is the paint can.
  • Example. I put the paint can in the cubby hole. View/Display paint
    can.
滥情稳全场 2025-01-21 03:21:44

在您提到的命令行下,我可以将图像文件夹中的图像与资源一起添加到 pdf 表中的单元格中。但我无法添加从相机拍摄的照片。

 PdfGridCell cell2 = row.cells[2];
 grid.rows[2].height = 200;
 cell2.imagePosition = PdfGridImagePosition.stretch;
 cell2.style.backgroundImage =
    PdfBitmap(await  _readImageData( 'urban-logo.jpg'),);
    Rect.fromLTWH(0, 0, 0, 0);
grid.draw(page: page, bounds: const Rect.fromLTWH(0, 0, 0, 0)) ;

您能更详细地写下您的答案吗?在此处输入代码

Under the command line you mentioned, I can add the image in the image folder with the asset to the cell in the pdf table. But I couldn't add the photo I took from the camera.

 PdfGridCell cell2 = row.cells[2];
 grid.rows[2].height = 200;
 cell2.imagePosition = PdfGridImagePosition.stretch;
 cell2.style.backgroundImage =
    PdfBitmap(await  _readImageData( 'urban-logo.jpg'),);
    Rect.fromLTWH(0, 0, 0, 0);
grid.draw(page: page, bounds: const Rect.fromLTWH(0, 0, 0, 0)) ;

Can you write your answer in a little more detail?enter code here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文