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 🙏

© 2024 – Pkg Stats / Ryan Hefner

print-paper

v1.0.12

Published

Generate corresponding paper and automatically change pages

Downloads

29

Readme

install

npm install print-paper

usage

import { Print } from 'print-paper'

const str =
  'Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit excepturi corrupti dicta expedita commodi! Velit, ab autem! Minima minus neque quam fugit, beatae ut recusandae dolorum quos repudiandae laudantium odio mollitia facilis esse quis veniam quia sed dolores doloribus vel. Quaerat suscipit incidunt ullam, totam molestiae exercitationem! Unde, ipsam numquam!'

const print = new Print('A5', 'horizontal', 0)
// size:A4 A5
// direction:horizontal 水平方向,vertical 垂直方向
// margin:纸张距离内容的距离,单位为mm

// 修改成你的容器
const container = document.querySelector('#app')

// 添加元素到容器中(这步操作必须在print.create()前执行)
container.appendChild(print.element)

// 通过setTemplate设置的模板将会重复出现在每一页
// 模板的位置请自行通过css设置,例如 position:absolute;bottom:0;height:40px;
print.setTemplate(`<div style="height:80px;line-height:80px;text-align:center;">Header</div>`)

// tips:对绝对定位的元素,若需要单行文字居中,请使用flex而非light-height
print.setTemplate(
  `<div style="display:flex;flex-direction:column;justify-content:center;position:absolute;left:0;bottom:0;width:100%;height:80px;text-align:center;">Footer</div>`
)

const arr = new Array(30).fill(0).map(() => ({
  name: str.slice(0, Math.ceil(Math.random() * 200) + 50),
}))
print.setData(arr)

// 通过setActiveTemplate设置单个动态模板,若纸张剩余空间不够,会自动创建新纸张并将未完成的打印数据书写在新纸张上
print.setActiveTemplate(data => {
  return `<div>${data.name}</div>`
})

// 生成打印内容
print.create()

// 自行打印:鼠标右键菜单-打印 | 控制台输入print()

tips

如果使用在 React 中。为避免产生元素重叠,请在元素添加到容器前设置容器的innerHTML''

container.innerHTML = ''
container.appendChild(print.element)