I'm creating a pdf with flutter using a 'pdf' package. So I want to insert an image in pdf. The problem is that then I don't know how to load an image from assets in the 'Image' package which is recommended to use in the 'pdf' package. Refrence:https://pub.dev/packages/pdf :pdf package refrence and https://pub.dev/packages/image: image package refrence
I have tried some code but none work
pdf.dart
import 'package:image/image.dart' as imgs;
final img1 = imgs.decodeImage(File('assets/logo.png').readAsBytesSync());
Image(PdfImage(
pdf.document,
height: 20,
width: 20,
image: img1.data.buffer.asUint8List(),
))
I have image in assests folder in project and I also have it in pubspec.yaml
file
I am expecting to load the image from the assets folder using the 'image' package. Or is there another way to load an image in 'pdf' package.
Some of the error when I use the above code:
E/PDFView (13223): load pdf error
E/PDFView (13223): java.io.FileNotFoundException: No such file or directory