JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q37872F
  • License ISC

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

Package Exports

  • @web2docx/web2docx-sdk
  • @web2docx/web2docx-sdk/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@web2docx/web2docx-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

โšก 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();

โš™๏ธ API Reference

Method Description
htmlToPdf(html: string) Convert single HTML to PDF (returns Buffer)
htmlBatchToPdf(htmlList: string[]) Convert multiple HTMLs into a ZIP (returns Buffer)
htmlToImage(html: string) Convert HTML to Image (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


Made with โค๏ธ by the Web2Docx team