Used Library: dart_pdf搜索后,我在GITHUB中发现了相同的问题,但无法解决该问题。我尝试了此操作,但出现了模糊的图像。请帮忙!!
ByteData data = await rootBundle.load('assets/test.jpg');
var codec = await instantiateImageCodec(data.buffer.asUint8List());
var frame = await codec.getNextFrame();
var imageBytes = await frame.image.toByteData();
PdfImage assetImage = PdfImage(pdf.document,
image: imageBytes.buffer.asUint8List(), width: 86, height: 80);
渲染图像:
最佳答案
改用这个:
final PdfImage assetImage = await pdfImageFromImageProvider(
pdf: pdf.document,
image: const AssetImage('assets/test.jpg'),
);