# @winman-f2e/html2img

> A library created by fle-cli.

Latest version **0.1.2** (published 2018-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @winman-f2e/html2img
pnpm add @winman-f2e/html2img
yarn add @winman-f2e/html2img
bun add @winman-f2e/html2img
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-09-07 |
| First published | 2018-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ansenhuang |
| Maintainers | ansenhuang, azgaga, liushichuan, longyunxia, sherrywu, wuww5511, yaochen, yun77op |
| Keywords | fle-cli, webpack |

## Links

- npm: https://www.npmjs.com/package/@winman-f2e/html2img
- npm.io page: https://npm.io/package/@winman-f2e/html2img

## Dependencies (1)

- [@axe/request](https://npm.io/package/@axe/request.md) ^0.5.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2018-09-07
- 0.1.1 — 2018-09-06
- 0.0.3 — 2018-06-06
- 0.0.2 — 2018-04-25
- 0.0.1 — 2018-04-24

## README

# html转图片

将html的页面转为图片

## 开始安装

```bash
$ npm install @winman-f2e/html2img
```

## 如何使用

```js
import html2img from '@winman-f2e/html2img'

html2img({
  html: '<h1>hello</h1>',
  width: 750,
  height: 750 * document.documentElement.clientHeight / document.documentElement.clientWidth
}).then(imgUrl => {
  if (imgUrl) {
    const img = new Image()
    img.src = imgUrl
    img.onload = () => {
      document.getElementById('root').innerHTML = `<img src="${imgUrl}" style="width: 100%;" alt="img" />`
    }
  } else {
    document.getElementById('root').innerHTML = '<h3>图片生成失败</h3>'
  }
}, errorMsg => {
  document.getElementById('root').innerHTML = `<h3>图片生成失败：${errorMsg}</h3>`
}).catch(console.error)
```

## API

options[object]

* html：页面的html字符串
* width：页面宽度
* height：页面高度

返回值：`Promise`，参数：

* resolve(imgUrl)：图片链接
* reject(errorMsg)：错误信息

## 环境配置

构建工具

``` bash
$ npm install -g fle-cli

# yarn
$ yarn global add fle-cli
```

命令说明

```bash
# 本地开发
fle dev

# 代码构建
fle build
```

查看更多说明： [构建文档](https://www.npmjs.com/package/fle-cli)

## 补充说明

【备注】

---
_Source: https://npm.io/package/@winman-f2e/html2img · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
