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

@web2docx/web2docx-sdk

v1.0.14

Published

Real-time HTML to PDF/Image conversion client for Web2Docx API

Readme

Web2Docx SDK

Convert HTML to PDF and Images using WebSocket-powered real-time API.


🚀 Features

  • Convert HTML to PDF (single)
  • Convert multiple HTMLs to PDFs (batch, returns ZIP)
  • Convert HTML to Image
  • Real-time WebSocket updates for job completion
  • Priority queueing (Free / Pro / Pro Max)

📦 Installation

npm i @web2docx/web2docx-sdk

or

yarn add @web2docx/web2docx-sdk

🔑 Get Your API Key

To use this SDK, you need an API key.

👉 Sign up at web2docx.com and generate your key from the dashboard.
Free and paid plans are available based on usage.


⚡ Usage

1. Import and Initialize

const { Web2DocxClient } = require("@web2docx/web2docx-sdk");

const client = new Web2DocxClient("YOUR_API_KEY");

2. HTML to PDF

const fs = require("fs");

async function htmlToPdfExample() {
  const html = "<h1>Hello World</h1>";
  const pdfBuffer = await client.htmlToPdf(html);

  fs.writeFileSync("output.pdf", pdfBuffer);
}

htmlToPdfExample();

3. HTML Batch to PDF (ZIP)

async function htmlBatchToPdfExample() {
  const htmlList = ["<h1>First Document</h1>", "<h1>Second Document</h1>"];
  const zipBuffer = await client.htmlBatchToPdf(htmlList);

  fs.writeFileSync("batch-output.zip", zipBuffer);
}

htmlBatchToPdfExample();

Note: Maximum 10 HTML documents per batch.


4. HTML to Image

async function htmlToImageExample() {
  const html = "<h1>Hello Image</h1>";
  const imageBuffer = await client.htmlToImage(html);

  fs.writeFileSync("output.png", imageBuffer);
}

htmlToImageExample();

5. HTML Batch to IMAGE (ZIP)

async function htmlBatchToImageExample() {
  const htmlList = ["<h1>First Document</h1>", "<h1>Second Document</h1>"];
  const zipBuffer = await client.htmlBatchToImage(htmlList);

  fs.writeFileSync("batch-output.zip", zipBuffer);
}

htmlBatchToImageExample();

Note: Maximum 10 HTML documents per batch.


6. HTML to Docx

async function htmlToDocxExample() {
  const html = "<h1>Hello Docx</h1>";
  const docxBuffer = await client.htmlToDocx(html);

  fs.writeFileSync("output.docx", docxBuffer);
}

htmlToDocxExample();

7. HTML Batch to DOCX (ZIP)

async function htmlBatchToDocxExample() {
  const htmlList = ["<h1>First Document</h1>", "<h1>Second Document</h1>"];
  const zipBuffer = await client.htmlBatchToDocx(htmlList);

  fs.writeFileSync("batch-output.zip", zipBuffer);
}

htmlBatchToDocxExample();

Note: Maximum 10 HTML documents per batch.


⚙️ API Reference

| Method | Description | | :------------------------------------- | :--------------------------------------------------------------- | | htmlToPdf(html: string) | Convert single HTML to PDF (returns Buffer) | | htmlBatchToPdf(htmlList: string[]) | Convert multiple HTMLs into a ZIP of PDFs (returns Buffer) | | htmlToImage(html: string) | Convert single HTML to Image (returns Buffer) | | htmlBatchToImage(htmlList: string[]) | Convert multiple HTMLs into a ZIP of Images (returns Buffer) | | htmlToDocx(html: string) | Convert single HTML to DOCX (returns Buffer) | | htmlBatchToDocx(htmlList: string[]) | Convert multiple HTMLs into a ZIP of DOCX files (returns Buffer) |


📡 How it Works

  • The SDK sends your request to the Web2Docx server.
  • WebSocket connection is used to listen for job completion events.
  • Once the server finishes conversion, your promise resolves automatically.
  • Queues: Free users are slower; Pro and Pro Max users get faster processing.

🧹 Notes

  • If a job takes more than 60 seconds, it times out and throws an error.
  • Make sure your API Key is correct and active.
  • Currently supports HTML input only (URL input coming soon).

🧾 License

MIT License


⭐️ Support Us

If you find Web2Docx useful, please consider giving us a star on GitHub — it helps us reach more developers and motivates us to keep improving. Thank you! 💜


Made with ❤️ by the Web2Docx team