# dom-capture

> 实现了HtmlElement的截图功能

Latest version **1.0.3** (published 2022-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install dom-capture
pnpm add dom-capture
yarn add dom-capture
bun add dom-capture
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-11-25 |
| First published | 2022-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rockyf |

## Links

- npm: https://www.npmjs.com/package/dom-capture
- npm.io page: https://npm.io/package/dom-capture

## Recent versions

- 1.0.3 (latest) — 2022-11-25
- 1.0.1 — 2022-11-25

## README

# HTML截图
实现了HtmlElement的截图功能

## Install
`yarn add dom-capture`  
or  
`npm i dom-capture`

## Usage
```js
import {capture} from 'dom-capture'

const result = await capture(document.getElementById('poster'));
let img = new Image();
img.src = result;
document.body.appendChild(img);
```

## RenderOptions
| 名称        | 类型                                                 | 必须  | 默认值    | 说明     |
|:----------|:---------------------------------------------------|:----|:-------|:-------|
| `type`    | 'canvas' &#124; 'jpeg' &#124; 'png' &#124; 'blob'  | 否   | 'png'  | 导出类型   |
| `qaulity` | number                                             | 否   | 0.7    | 导出图片质量 |

## 开启调试
```js
window['dom-capture/debug-mode'] = true
```

## 注意点
* 仅支持的元素有：`img`、`text`、`canvas(svga/spine/lottie)`
* 不支持`transform`变换
* ~~文本仅只是`Arial`字体，建议给元素设置为`Arial`字体~~
* 1.0.28开始支持自定义字体，前提是确保设备上有字体或者引入了字体
* 不支持`z-index`样式
* 不支持下划线样式
* 不支持所有滤镜
* 不支持文本超出点点点(`ellipsis`)
* 不支持`img`填充样式
* 不支持`overflow`样式
* 不支持跨域的图片
* 换行文本需要加样式：`overflow-wrap: break-word;`

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