I'm trying to put an image on a PDF. I have this code:
But when I try to initialize the PDF I get the error:
E/flutter ( 1231): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type 'PdfReferenceHolder' is not a subtype of type 'PdfDictionary?' in type cast
The var "firma" is a File variable. What can I do?
Syncfusion Flutter Pdf provide support to load the image in JPG and PNG format. So we cannot able to load image using the file stream. We request to follow the below steps to load and draw the image to the pdf document:
//Draw an image.
graphics.drawImage(PdfBitmap(await _readImageData('photo.jpg')), Rect.fromLTWH(107, 50, 300, 300));
Please follow the below links for more information,
If this does not satisfy your requirement, we request you share the image file with us. So that will be helpful for us to assist you further in this.
I have tried to follow the steps indicated in the link. But they are not useful to me. Is there any way to show you the code better so that you can help me?
I enclose a screenshot of the error that it gives me even following your steps. Cheers!
We were unable to reproduce the reported behavior from our side. The reported code sample is working as expected without any exceptions. We have attached a simple sample to draw images from assets and URLs from our side and have attached its generated output. Kindly run this sample for reference and let us know the results obtained from your side.
Sample and generated output link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/image_to_pdf_sample-556604858
It seems that the problem is the version of the SDK. I'm looking to upgrade my project's SDK and see if this was the problem. As soon as I can I'll tell you something
Hello again. I have found the problem. The problem was that I had a PDFDocument.fromBase64String. I don't know if you take into account the reason for the failure, but it would be interesting that just as you can enter text in a preloaded PDF, you can also enter images.
We have tried to reproduce the reported issue with the provided details on our end. but it is working properly. we suspect that the issue may be because of the document specific. we request you share the simple sample, and input documents like pdf and image files with us. so that will be helpful for us to assist you further in this.
Please let us know if you need any further assistance with this.