0

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>');
  });
}

2 Answers 2

1

Answer when the Question was: How to add circular-image using html string in Flutter? Image not displaying

  1. Have you added your Image to the Asset Section in the pubspec.yaml (https://flutter.dev/docs/development/ui/assets-and-images)

  2. If yes: Can you access it in the Flutter Code using Image.asset('path/yourimage.png'),

  3. Try to use the ImageProvider like in the Example here: https://pub.dev/packages/printing#-readme-tab- (You will not be able to use HTLM then)

Answer when the Question was: How to add circular-image using html string in Flutter

You can use the border-radius: 50% property on your Image.

In your case the following should work: '<html><body><table><tr><td><img src="assets/profyl.jpg" alt="Avatar" style="border-radius: 50%;"></td><td>Purple</td></tr></table></body></html>'

See this example here: https://www.w3schools.com/css/css3_images.asp

Or the reference here: https://developer.mozilla.org/de/docs/Web/CSS/border-radius

Sign up to request clarification or add additional context in comments.

2 Comments

Image is not displaying. So, is the reason behind this?
I am not sure what you mean? So your Image is not even showing up in your pdf export? This is not mentioned in your question. EDIT OK you added it now with Edit Nr. 6
0

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%;">

2 Comments

Did you eventually figure it out for iOS? I'm having the same issue now.
Not till now !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.