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

win32-pdf-printer

v5.0.0

Published

A simple and powerful printing library for node and elctron environments.

Downloads

71

Readme

Node.js & electron print library

A simple and powerful printing library for node and elctron environments.

  • Support for getting the paper size supported by the printer
  • Support for getting the number of printer queues
  • Support to get the printer status
  • Small size and strong performance
  • Powerful compatibility, the core program can even run on - windows xp
  • Works on Windows only
    • Supported OS: Windows 10, Windows 8, Windows 7, Vista.
    • For XP use You just need to download a 3.1.2 SumatraPDF software and specify the path when calling the print api.

install

npm add win32-pdf-printer

use

import { join } from "node:path";
import {
  print,
  print2,
  getPaperSizeInfoAll,
  getPaperSizeInfo,
  getDefaultPrinter,
  getPrinters
} from "win32-pdf-printer";

// 打印所有打印机支持的纸张大小
console.log(JSON);

// 获取默认打印机支持的纸张大小
console.log(JSON.stringify(getPaperSizeInfoAll()));

// 获取指定打印机支持的纸张大小
// let PrinterPaperSizeInfo = getPaperSizeInfo({ printer: '\\\\192.168.0.126\\HP LaserJet Tank 1020 PCLmS (V3)' });

// 获取默认打印机名称
let DefaultPrinterName = getDefaultPrinter()?.PrinterName

// 获取所有打印机名称信息
let AllPrinterName = getPrinters()

// 打印测试
print(join(__dirname, "mlmdflr.pdf"), {
  printer: DefaultPrinterName,
  paperSize: DefaultPrinterPaperSizeInfo?.PaperSizes[0].PaperName,
});

print2(join(__dirname, "mlmdflr.pdf"),DefaultPrinterName);

out

[
  {
    "PrinterName": "打印烧鸡",
    "TaskNumber": 8,
    "Status": 0,
    "StatusMsg": "准备就绪(Ready)",
    "PaperSizes": [
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "Custom(72.0mm * 297.0mm)",
        "RawKind": 256,
        "Width": 283
      },
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "72mm * 297mm",
        "RawKind": 257,
        "Width": 283
      },
      {
        "Height": 1654,
        "Kind": 0,
        "PaperName": "72mm * 420mm",
        "RawKind": 258,
        "Width": 283
      },
      {
        "Height": 12898,
        "Kind": 0,
        "PaperName": "72mm * 3276mm",
        "RawKind": 259,
        "Width": 283
      }
    ]
  },
  {
    "PrinterName": "HP LaserJet Tank 1020 PCLmS (V3)",
    "TaskNumber": 9,
    "Status": 4,
    "StatusMsg": "正在删除(Pending Deletion)",
    "PaperSizes": [
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "Custom(72.0mm * 297.0mm)",
        "RawKind": 256,
        "Width": 283
      },
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "48mm * 297mm",
        "RawKind": 257,
        "Width": 189
      },
      {
        "Height": 1654,
        "Kind": 0,
        "PaperName": "48mm * 420mm",
        "RawKind": 258,
        "Width": 189
      },
      {
        "Height": 12898,
        "Kind": 0,
        "PaperName": "48mm * 3276mm",
        "RawKind": 259,
        "Width": 189
      }
    ]
  },
  {
    "PrinterName": "\\\\192.168.0.126\\HP LaserJet Tank 1020 PCLmS (V3)",
    "TaskNumber": 0,
    "Status": 0,
    "StatusMsg": "准备就绪(Ready)",
    "PaperSizes": [
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "Custom(72.0mm * 297.0mm)",
        "RawKind": 256,
        "Width": 283
      },
      {
        "Height": 1169,
        "Kind": 0,
        "PaperName": "72mm * 297mm",
        "RawKind": 257,
        "Width": 283
      },
      {
        "Height": 1654,
        "Kind": 0,
        "PaperName": "72mm * 420mm",
        "RawKind": 258,
        "Width": 283
      },
      {
        "Height": 12898,
        "Kind": 0,
        "PaperName": "72mm * 3276mm",
        "RawKind": 259,
        "Width": 283
      }
    ]
  }
]

队列图片

License

MIT