We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Error generating PDF via grid toolbar

I'm trying to insert an image into the PDF file generated by Grid, but the error below appears:

Provided key is not valid. in syncfusion

I'm converting the JPG image to base64 as it should be.

The rest of the PDF works, but if you try to insert the image the error appears.

I have no idea what that might be.

Attached follows the images of the code.



Attachment: images_9fe66d75.rar

5 Replies

MS Madhu Sudhanan P Syncfusion Team March 11, 2019 06:52 AM UTC

Hi Fabiano, 

Thanks for contacting Syncfusion support. 

The reported problem happens when the provided base64 string is not formatted properly or the given image is in format other than JPEG. To troubleshoot this problem, please share the base64 string or the original image to analyze at our end. Also please ensure whether imageHeader variable holds the encoded string value before sending   

Regards, 
Madhu Sudhanan P 



FM Fabiano Melo March 11, 2019 10:20 AM UTC

Hi, thanks for the feedback.

Attached is the image that my function turns into base64 and also a text file with the generated alphanumeric sequence.

A great day at work.

Attachment: base64AndImage_901bb659.rar


MS Madhu Sudhanan P Syncfusion Team March 11, 2019 10:54 AM UTC

Hi Fabiano, 

Thanks for the update. 

When converting the image to data URI, the following string appended which is the cause of the problem. Before providing the encoded string to the PDF export, please strip of the above string as follows to resolve this problem. 


this.imageHeader = dataUrl.slice('data:image/jpeg;base64,'.length); 


Regards, 
Madhu Sudhanan P 



FM Fabiano Melo March 11, 2019 11:33 AM UTC

Many thanks Madhu Sudhanan.

this.imageHeader.replace('data:image/jpeg;base64,','');

Worked perfectly!


MS Madhu Sudhanan P Syncfusion Team March 11, 2019 11:45 AM UTC

Hi Fabiano, 
  
Thanks for the update. 
  
Regards, 
Madhu 


Loader.
Live Chat Icon For mobile
Up arrow icon