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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alexsun-top/office2pdf

v0.1.1

Published

Node-first TypeScript bindings for office2pdf via Rust/WASM.

Readme

@alexsun-top/office2pdf

Node-first TypeScript binding for office2pdf = "0.6" via a generated WebAssembly bridge.

  • No LibreOffice service
  • No Chromium/Docker/browser-only wrappers
  • No Python/CLI dependency

Install

npm install @alexsun-top/office2pdf

Usage

import {
  convertBytes,
  convertDocxToPdf,
  convertPath,
  convertToPdf,
  inferFormat,
  __version__,
  Format,
} from "@alexsun-top/office2pdf";
import { writeFile } from "node:fs/promises";

// infer extension before conversion
const format = inferFormat("/tmp/report.docx"); // "docx"

// convert local file
const result = await convertPath("/tmp/report.docx");
await writeFile("/tmp/report.pdf", result.pdf);

// convert bytes
const input = new Uint8Array([
  /* office file bytes */
]);
const { pdf, warnings, metrics } = await convertBytes(input, Format.DOCX, {
  includeWarnings: true,
  paperSize: "A4",
});

// upstream-compatible JS/WASM helper style: returns PDF bytes only
const helperPdf = await convertDocxToPdf(input);
const genericPdf = await convertToPdf(input, "docx");

API

  • __version__: string
  • Format: { DOCX: "docx"; PPTX: "pptx"; XLSX: "xlsx"; docx: "docx"; pptx: "pptx"; xlsx: "xlsx" }
  • inferFormat(pathOrUrl: string | URL): "docx" | "pptx" | "xlsx"
  • convertBytes(data, format, options?)
  • convertPath(pathOrUrl, options?)
  • convertToPdf(data, format) -> Promise<Uint8Array>
  • convertDocxToPdf(data) -> Promise<Uint8Array>
  • convertPptxToPdf(data) -> Promise<Uint8Array>
  • convertXlsxToPdf(data) -> Promise<Uint8Array>

ConvertOptions accepts both camelCase and snake_case aliases:

  • sheetNames / sheet_names
  • sheetFilter / sheet_filter compatibility alias for sheet_names
  • slideRange / slide_range
  • paperSize / paper_size
  • fontPaths / font_paths
  • pdfStandard / pdf_standard
  • includeWarnings / include_warnings
  • pdfUa / pdf_ua
  • streamingChunkSize / streaming_chunk_size

It also accepts upstream boolean options tagged and streaming.

Rust-native upstream APIs map to this Node package as follows:

  • office2pdf::convert(path) and convert_with_options(path, options) correspond to convertPath(path, options?).
  • office2pdf::convert_bytes(data, format, options) corresponds to convertBytes(data, format, options?).
  • render_document is not exposed because this package does not expose the upstream IR document model.

Unsupported by upstream office2pdf 0.6:

  • pageRange / page_range -> throws
    • page_range is not supported by upstream office2pdf 0.6
  • memoryLimitMb / memory_limit_mb -> throws
    • memory_limit_mb is not supported by upstream office2pdf 0.6

Result shape

{
  pdf: Uint8Array;
  warnings: string[];
  metrics: null | {
    parseDurationMs: number;
    codegenDurationMs: number;
    compileDurationMs: number;
    totalDurationMs: number;
    inputSizeBytes: number;
    outputSizeBytes: number;
    pageCount: number;
  };
}

CLI

Build exports a office2pdf command:

office2pdf --help
office2pdf --version
office2pdf input.docx output.pdf
office2pdf input.docx -o output.pdf
office2pdf input.xlsx --outdir ./pdfs
office2pdf --paper A4 --landscape --pdf-a input.docx output.pdf
office2pdf --sheets Sheet1,Sheet2 input.xlsx output.pdf
office2pdf --slides 1-3 input.pptx output.pdf
office2pdf --font-path /path/font-a.ttf --font-path /path/font-b.ttf input.docx output.pdf

Supported flags: -o / --output, --outdir, --paper, --landscape, --pdf-a, --sheets, --slides, and repeatable or comma-separated --font-path.

Scripts

  • npm run wasm:build — build wasm artifacts to wasm/pkg
  • npm run build — build wasm (release), copy publishable wasm files, and compile TypeScript
  • npm run typecheck — TypeScript typecheck
  • npm test — run Vitest
  • npm run check — typecheck + tests + format check

Development

  • Rust crate: rust/
  • TypeScript entrypoints: src/index.ts, src/cli.ts, src/native.ts
  • Tests: tests/index.test.ts, tests/cli.test.ts, tests/real-conversion.test.ts

Release

GitHub Actions runs package checks on every branch push and pull request. The publish workflow runs only when a version tag matching v*.*.* is pushed, for example v0.1.0.

The npm package name is @alexsun-top/office2pdf. For the first manual public publish of this scoped package, run the same local checks and publish with explicit public access:

npm ci
npm run check
npm run build
npm publish --access public

Do not create or push a release tag until the target npm version, exact tag name, remote push target, and publish path have been explicitly approved.

The publish workflow is designed for npm Trusted Publishing with GitHub Actions OIDC. To enable automatic npm authentication without long-lived tokens:

  1. Open the package settings on npmjs.com.
  2. Add a trusted publisher for agentsyaml/office2pdf-ts.
  3. Set the trusted workflow file to .github/workflows/publish.yml.
  4. Allow the workflow to run npm publish --access public.

The workflow grants id-token: write, so npm can exchange the GitHub OIDC token during npm publish --access public. No NPM_TOKEN secret is required for this path, and no generated dist/ or wasm/pkg/ files need to be committed.

If Trusted Publishing is unavailable, create an npm automation token, store it as the GitHub Actions secret NPM_TOKEN, configure actions/setup-node with registry-url: https://registry.npmjs.org, and pass the secret only to the publish step as NODE_AUTH_TOKEN. Never commit token values.