Skip to content

feat: add PDF generation and manipulation tools #777

Description

@avoidwork

Summary

Add PDF generation and manipulation capabilities — create PDFs from markdown/HTML, merge/split PDFs, and add watermarks, signatures, and annotations.

Motivation

The agent can read PDFs but has no way to produce or modify them. This blocks any workflow that requires generating reports, contracts, or documents as PDF output, or manipulating existing PDFs (merging, splitting, watermarking). Without PDF writing, the agent's document capabilities are fundamentally one-sided.

Proposed Solution

Implement a PDF tool (or tools) that leverages a Node.js PDF library such as pdf-lib for manipulation and puppeteer or playwright for HTML-to-PDF conversion. Capabilities should include:

  • Generate PDF from markdown/HTML: Convert rendered markdown or HTML strings into PDF files.
  • Merge PDFs: Combine multiple PDF files into a single document.
  • Split PDFs: Extract page ranges or individual pages from a PDF.
  • Watermarks: Add text or image watermarks to existing PDFs.
  • Signatures: Embed signature images or text into PDF pages.
  • Annotations: Add highlights, notes, or other annotations to PDF pages.

The tool should accept file paths or base64-encoded content and return file paths or base64-encoded output.

Alternatives Considered

  • Server-side PDF generation via an external API — rejected because it introduces network dependency and latency.
  • Shell-based tools like wkhtmltopdf — rejected because they require system-level dependencies that may not be available in all environments.

OpenSpec Note

This project uses OpenSpec for feature development. If this request is approved, I will:

  1. Run /opsx:propose to generate a full proposal with specs and tasks
  2. Iterate on the design before any code is written
  3. Follow the task-driven implementation workflow

Additional Context

Existing PDF reading capability already exists in the codebase. This feature would complete the PDF read/write cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions