【问题标题】:Convert HTML to Image in React Native在 React Native 中将 HTML 转换为图像
【发布时间】:2019-04-30 00:14:54
【问题描述】:

我目前正在尝试从 React Native 中的 html 字符串生成图像(png/jpg),如下所示:

<table><tr><th>Company</th><th>Contact</th><th>Country</th></tr><tr><td>AlfredsFutterkiste</td>" +
        "<td>MariaAnders</td><td>Germany</td></tr><tr><td>CentrocomercialMoctezuma</td><td>FranciscoChang</td>" +
        "<td>Mexico</td></tr><tr><td>ErnstHandel</td><td>RolandMendel</td><td>Austria</td></tr><tr>" +
        "<td>IslandTrading</td><td>HelenBennett</td><td>UK</td></tr></table>

我发现了一些很好的第三方实现,它们可以从 html 字符串 (https://github.com/christopherdro/react-native-html-to-pdf) 生成 pdf,但没有一个可以从 html 生成图像。

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: html react-native png


    【解决方案1】:

    这里有 2 个节点包可以帮助您将给定的 DOM 转换为 svg/png/jpeg 图像:

    https://github.com/tsayen/dom-to-image

    https://www.npmjs.com/package/html-to-image

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-17
      • 2019-05-27
      • 1970-01-01
      • 2019-07-12
      • 2018-06-14
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多