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

goodcom-web-printer

v1.0.1

Published

Goodcom Web Printer SDK

Downloads

198

Readme

Goodcom Web Printer SDK

This project is an SDK for web applications to connect to Goodcom printers via WebSocket and send printing commands. It encapsulates the underlying WebSocket communication, providing simple APIs for printing HTML, PDF, images.

Features

  • Provides APIs for sending various print jobs.
  • Supports two common web project integration methods: <script> tag and npm module.

Quick Start

You can integrate the SDK into your project using either of the following methods, depending on your project type.

Method 1: Using <script> Tag

Suitable for static HTML pages or projects without build tools.

  1. Include the SDK in your index.html file, either in the <head> or at the bottom of the <body>:

    <script src="https://www.igoodcom.com/sdk/goodcom-printer-sdk.umd.cjs"></script>
  2. After inclusion, the SDK will expose a global variable window.GoodcomPrinterSDK. You can destructure it to get the GcPrinter instance class:

    const { GcPrinter } = window.GoodcomPrinterSDK;
       
    document.getElementById('myButton').onclick = async () => {
      try {
        await GcPrinter.printBase64Image(base64String);
        console.log("successfully");
      } catch (e) {
        console.error("Failed to connect to printer:", e.message);
      }
    };

Method 2: Using npm (Recommended)

Suitable for modern front-end projects using npm/yarn and bundlers (like Vite, Webpack).

  1. Install the goodcom-web-printer package:

    npm install goodcom-web-printer
  2. Import the required modules in your JavaScript or TypeScript file:

    import { GcPrinter } from 'goodcom-web-printer';
    /**
    For older Node.js environments that do not support ES Modules.
    const { GcPrinter } = require('goodcom-web-printer');
    */
       
    async function handlePrint() {
      try {
        await GcPrinter.printBase64Image(base64String);
        console.log("Print successful");
      } catch (e) {
        console.error("Print failed:", e.message);
      }
    }

API Documentation

1. GcPrinter (Main Printer Instance)

The SDK exports a default, instantiated GcPrinter object, which connects to ws://localhost:62769.

Methods (all methods are asynchronous and return a Promise):
  1. printHtml(htmlString: string) : Sends an HTML string to the printer for rendering and printing.
    • htmlString: A string containing HTML tags.
  2. printPdf(file: File): Sends a PDF File object for printing.
    • file: A File object, typically from an input type="file".
  3. printBase64Image(base64Image: string): Sends a Base64-encoded image string for printing.
    • base64Image: The pure Base64 string, without the data:image/...;base64, prefix.