Introduction

Aspose.PDF FOSS for TypeScript is a new open-source library for working with PDF documents from Node.js code. It is released under the MIT license and ships as the @asposefoss/pdf package, requiring only Node.js (>=22) at runtime — there are no other runtime dependencies.

The library is organized around the Document and Page classes. Document.OpenFile() and Document.Open() load a PDF from disk or in-memory bytes, and Document.New() starts a blank document; each page in doc.Pages exposes methods for adding text, images, annotations, and AcroForm fields, as well as converting itself to other formats. From there, the API covers splitting, merging, and reordering pages, converting documents to HTML, Markdown, DOCX, SVG, and raster images, adding and flattening annotations, building interactive forms, and encrypting, signing, or redacting the result.

This release is for developers who need PDF processing inside a Node.js or TypeScript codebase without a commercial license: document assembly pipelines, publishing tools that render PDFs to web-ready formats, form-filling automation, and services that need to redact or encrypt sensitive PDFs before distribution. The project is currently at version 0.1.0 and under active early-stage development, so APIs and feature coverage may evolve before a stable release.


What’s Included

Document and Page Management

Document.OpenFile() / Document.Open() load a PDF from disk or an in-memory Uint8Array; Document.New() starts a blank document. Pages can be split into separate documents with Document.Split(), extracted with Document.ExtractPages(), merged with Document.Merge(), or appended to an existing document with Document.Append(). Document.WriteTo() writes the result back out, optionally compressed.

import { Document } from '@asposefoss/pdf';

// Open from disk (or Document.Open(uint8array) for in-memory data)
const doc = Document.OpenFile('input.pdf');

// Inspect and edit pages
const pages = doc.Pages;
console.log(pages.length);
pages[0].Rotate = 90;
doc.RemovePage(2);                 // 1-based page number
doc.Reorder([3, 1, 2]);

// Save
doc.WriteTo('output.pdf');         // or: const bytes = doc.Save();

Format Conversion

Whole documents render to HTML with Document.ToHtml() and to GitHub-flavored Markdown with Document.ToMarkdown(). Individual pages render to standalone SVG with Page.ToSvg() or raster PNG bytes with Page.ToImage(). Document.ToDocx() / Page.ToDocx() produce reflowed or fixed-layout .docx output.

import { Document } from '@asposefoss/pdf';
const doc = Document.OpenFile('in.pdf');
const png = doc.Pages[0].ToImage({ scale: 2 }); // Uint8Array of PNG bytes @144 DPI
const html = doc.ToHtml();                 // standalone semantic HTML, all pages
const md = doc.ToMarkdown();               // GFM Markdown, all pages
const docx = doc.ToDocx();                 // .docx bytes, reflowed, images in the package

Annotations

Each Page exposes annotation methods directly: Page.AddHighlight(), Page.AddUnderline(), Page.AddSquiggly(), and Page.AddStrikeOut() add text markup; Page.AddTextNote(), Page.AddFreeText(), and Page.AddStamp() add sticky notes, free-standing text, and rubber-stamp annotations. Typed subtypes such as MarkupAnnotation and StampAnnotation expose a Flatten() method to bake the annotation into page content.

AcroForms

The Form class builds interactive fields directly: AddTextField(), AddCheckbox(), AddRadioGroup(), AddComboBox(), AddListBox(), and AddPushButton() each return a typed Field subclass. Calling SetStyle() or GenerateAppearance() on a field refreshes its rendered appearance, and Document.FlattenForm() bakes every field’s current value into static page content.

function addFormFields(doc: Document, page: Page): void {
  const form = doc.Form;
  const pageNum = page.Number;

  // Text field
  form.AddTextField({
    page: pageNum, rect: [200, 670, 450, 690], name: 'FullName', value: 'Alice Sample',
  });

  // Checkbox
  form.AddCheckbox({
    page: pageNum, rect: [200, 630, 218, 648], name: 'Subscribe',
    checked: true,
  });
}

Security and Redaction

Document.WriteTo() accepts an encrypt option supporting AES-128, AES-256, or RC4, with a separate user and owner password and granular Permissions. Sensitive regions or matched text can be permanently removed with Document.Redact(), Document.RedactText(), and Page.ApplyRedactions(), configured through RedactOptions.

import { Document } from '@asposefoss/pdf';
const doc = Document.OpenFile('in.pdf');
doc.WriteTo('locked.pdf', {
  encrypt: {
    userPassword: 'open-me',       // required to open (default '')
    ownerPassword: 'full-rights',  // default: same as userPassword
    algorithm: 'aes256',           // 'aes256' (default) | 'aes128' | 'rc4'
    permissions: { copying: false, modifying: false },
    encryptMetadata: true,
  },
});

Quick Start

Install the package, then open an existing PDF, edit its pages and metadata, and save the result:

asposefoss/pdf is not yet published — build from source until it ships. See the project README for build instructions.
import { Document } from '@asposefoss/pdf';

// Open from disk (or Document.Open(uint8array) for in-memory data)
const doc = Document.OpenFile('input.pdf');

// Inspect and edit pages
const pages = doc.Pages;
console.log(pages.length);
pages[0].Rotate = 90;
doc.RemovePage(2);                 // 1-based page number
doc.Reorder([3, 1, 2]);

// Metadata
doc.SetMetadata({ title: 'Report', author: 'Jane', custom: { Dept: 'R&D' } });

// Save
doc.WriteTo('output.pdf');         // or: const bytes = doc.Save();
doc.WriteTo('small.pdf', { compressed: true }); // xref stream + object streams

Supported Formats

FormatExtensionReadWrite
PDFpdf
Markdownmd
SVGsvg
TIFFtiff
DOCXdocx
HTMLhtml
PNGpng
EPUBepub

Open Source & Licensing

Aspose.PDF FOSS for TypeScript is released under the MIT license, with source published on GitHub. There is no evaluation watermark, usage limit, or separate license file to manage, and the library may be used in commercial products without royalties.

The package is currently at version 0.1.0, reflecting active early-stage development. Node.js (>=22) is the only runtime requirement, and the package has no other third-party dependencies.


Getting Started