Afur / flutter_html_to_pdf

Flutter plugin for generating PDF files from HTML
MIT License
69 stars 126 forks source link

how to add image directly to page #3

Closed xyzbilal closed 5 years ago

xyzbilal commented 5 years ago

Hi, I just start to use this package. it is ok to convert text inputs to pdf but I want to add picture from library to pdf page. any information how to do it.

xyzbilal commented 5 years ago

I just solved it with converting image to base64 and adding it to body. I share it if someone needs also.

` var image = File(image.path).readAsBytesSync(); var base64Image = base64Encode(image); var content = """ <!DOCTYPE html>

Sender : ${shared.fax}
Date : $date
""";`
leewonghao commented 4 years ago

I just solved it with converting image to base64 and adding it to body. I share it if someone needs also.

var image = File(image.path).readAsBytesSync(); var base64Image = base64Encode(image); var content = """ <!DOCTYPE html> <html> <head> <tr> <td>Sender :</td> <td>${shared.fax}</td> <div style="margin-bottom: 20px;display: block;text-align: right;"> <td>Date :</td> <td>$date</td> </div> </head> <body> <img src="data:image/png;base64,$base64Image" style="height: 90%;" /> </body> </html> """;

Yes, It 's worked. Thanks for your solved.