bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.41k stars 505 forks source link

Does not work on android phone #321

Open BrandaoDesign opened 1 year ago

BrandaoDesign commented 1 year ago

The plugin works correctly in the ionic v4 browser, but when I build it through Android Studio and run on Xiaomi Redmi N 8, Android 10, API 29, it doesn't show any error in the browser's inspect, but the image is not generated.

Expected behavior Trying to generate an image through html using id

current behavior The image is secured when the application runs through ion in the browser but when building and running the application on the mobile it does not run the application on the mobile it does not run the function

steps to

  1. Install ionic v4
  2. Install the html-to-image plugin
  3. Open with capacitor in android studio
  4. Run the application on the cell phone
  5. your environment *html-to-image: 1.10.8

    • Ionic V4 - Android
    • Redmi 8
vivcat[bot] commented 1 year ago

👋 @BrandaoDesign

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

BrandaoDesign commented 1 year ago

How to make this plugin work with capacitor?

aeharding commented 7 months ago

I am also experiencing this problem. When running inside an Android Webview via Capacitor, html-to-image fails to render if the DOM tree contains an image.

Unfortunately the error is not helpful - just literally "Error"

Here's the error:

image

EDIT: Solved

The problem was having

    CapacitorHttp: {
      enabled: true,
    },

in my capacitor.config.json. I removed this and the images started loading normally.

1907382219 commented 3 months ago

maybe ionic or angular overwrite class FileReader, then FileReader in html-to-image cannot find some methods and return noting. So what I did was fix it. so needs to be corrected when the project starts to load. image

it may not be the best solution, but it works!