npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wowjoy/print

v0.6.50

Published

report print utils

Downloads

22

Readme

华卓平台中心打印工具

安装

npm install -S @wowjoy/print

API

htmlPrint 打印html

语法

htmlPrint(ele: HTMLElement, isPreview?: boolean): promise

使用方法

import {htmlPrint} from "@wowjoy/print"
htmlPrint(document.querySelector('.print')).then(() => {
  console.log("htmlPrint success")
})

函数定义

interface IHtmlPrintParams {
  isPreview?: boolean,
  printer?: number | undefined | string
}
export async function htmlPrint(ele: HTMLElement, params: IHtmlPrintParams): Promise<string>
export async function htmlPrint(ele: HTMLElement, isPreview?: boolean): Promise<string>

参数

  • ele HTMLElement 需要打印的 html 元素
  • isPreview boolean 是否开启预览模式
  • printer string | number | undefind 打印机名称 或者序号 可以通过 getPrinters 获取打印机列表

pdfPrint 打印 pdf 当 isPreview 为true 是 会用浏览器的打印 否则是静默打印

语法

import {pdfPrint} from "@wowjoy/print"
pdfPrint(pdfurl: string, isPreview?: boolean = false)

函数定义

interface IPdfPrintParmas {
  /* pdf 链接 */
  url: string,
  isPreview? : boolean,
  printer?: undefined | string | number,
}
export async function pdfPrint(url: string, isPreview?: boolean): Promise<any>;
export async function pdfPrint(params: IPdfPrintParmas): Promise<any>;

参数

  • pdfurl string 可以为具体的 http 链接 或者 存储服务返回的 key 值 如果不是http链接 会把他当成存储接口返回的key值
  • isPreview boolean 是否开启预览模式
  • printer undefined | string | number 打印机名称 或者序号 可以通过 getPrinters 获取打印机列表

templatePrint 配置模版的打印

import {templatePrint} from "@wowjoy/print"
async function templatePrint (templateId: string, params?:Record<string, any> | boolean, isPreview?: boolean) => Promise

函数定义

interface ITemplatePrintParams {
  /* 模版id  */
  templateId: string,
  /** 模版参数 */
  params?: Record<string, string>,
  /* 是否预览 */
  isPreview?: boolean,
  /* 打印机 name 或者 index 只有在静默打印的时候生效 */
  printer?: string | number
}

export async function templatePrint(params: ITemplatePrint): Promise<string>
export async function templatePrint(templateId: string, params: Record<string, string>, isPreview?: boolean): Promise<string>
export async function templatePrint(templateId: string): Promise<string>
export async function templatePrint(templateId: string, isPreview: boolean): Promise<string>

参数

  • templateId: string | ITemplatePrintParams - 积木报表生成的模板id
  • params: object | boolean 拼接到url后面的参数 为boolean 时 会当做
  • isPreview: boolean 是否开启预览
  • printer undefined | string | number 打印机名称 或者序号 可以通过 getPrinters 获取打印机列表

返回值

promise

templateUploadPdf 只上传 pdf

async function templateUploadPdf(templateId: string, params?: Record<string, any>): Promise

参数

  • templateId 积木的模版id
  • params 拼接在后面的参数

getLodop 获取lodop 对象 获取后可自行调用lodop打印接口 文档参考lodop文档

用法

import {getLodop} from "@wowjoy/print"
(async () => {
  let lodop = await getLodop()
  // lodop.xxx()
})()

getPrinters 获取所有打印接列表

用法

import {getPrinters} from "@wowjoy/print"
(async () => {
  let printers = await getPrinters()
  console.log('printers', 'printers')
})()

loadLodop 检测是否存在lodop

用法

import {loadLodop} from "@wowjoy/print"
loadLodop().then(() => {console.log('存在')}).catch(() => {console.log('不存在')})

vscode 查看文档技巧

  1. 有重载的函数 mac command + shift + space win ctrl + shift + sapce 然后上下键可以选择查看不同的重载