1.0.2 • Published 7 months ago

eprint-web v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

eprint-web

api

eprint

eprint(options: IPrintOptions | string)

使用

  import { eprint } from 'eprint-web';

  eprint({
    content: document.querySelector('#app')!,
  }).then((...args) => {
    console.log('printform done', ...args)
  }).catch((error) => {
    console.log('printform error', error)
  })

当参数类型为 string 时, 会将 string 当成 url

参数

interface IPrintOptions {
  url?: string,
  content: HTMLElement,
  type?: 'html' | 'canvas',
  color?: boolean,
  printerName?: string,
  silent?: boolean,
  footer?: string,
  header?: string,
  pageSize?: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6",
  showPageNumbers?: boolean,
}

当 content 为 HTMLElement 时, 会忽略 url 参数;

返回

Promise

注意事项

当 type 为 html 时;

  1. 不要在样式表中使用 @import 相对路径;
  2. background-image 请使用完整路径的图片地址 eg: https://wowjoy.cn/xxx.jpg;
  3. 打印元素的子元素请不要使用 fixed 定位;
1.0.2

7 months ago

1.0.0

7 months ago