我想将用相机拍摄的照片插入到pdf表格的单元格中。但我收到以下错误代码
// 我想将相机拍摄的照片插入到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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我要开始的地方。您没有将照片用作对象。您已选择使用图像作为样式。该样式需要调用存储位置而不是将照片视为对象。
能。
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.
can.
在您提到的命令行下,我可以将图像文件夹中的图像与资源一起添加到 pdf 表中的单元格中。但我无法添加从相机拍摄的照片。
您能更详细地写下您的答案吗?
在此处输入代码
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.
Can you write your answer in a little more detail?
enter code here