Search code examples
cssflutterdartpdf-generationdart-html

How to display image in pdf using html-string in flutter iOS app?


Edit: I have posted the answer for Android but still unknown about iOS case.

How to create the circular image using html-string in flutter? src="assets/test.jpg" OR src="file:///assets/profyl.jpg" is not working.

Here's what I have:

Future<void> _printPdfAsHtml() async {
  print('Print ...');
  await Printing.layoutPdf(onLayout: (PdfPageFormat format) async {
    return await Printing.convertHtml(
        format: format,
        html:
            '<html><body><table><tr><td><img src="assets/test.jpg" alt="Avatar"></td><td>Purple</td></tr></table></body></html>');
  });
}

Solution

  • This work for android case but not for iOS.

    <img src="file:///android_asset/flutter_assets/assets/profyl.jpg" alt="Avatar" height="100" width="100 style="border-radius: 50%;">