# PDF Forge & Layout Diagnostics Edge API (v1.0.0)

> Compile Markdown or HTML into polished multi-page PDF 1.7 documents with orphan-page & wide-table diagnostics in <20ms.

Zero-dependency Markdown & HTML to spec-compliant PDF 1.7 compiler with corporate themes ('executive', 'invoice', 'technical', 'memo'), multi-page table header continuation, diagonal watermarks, deterministic layout diagnostics (orphan pages, wide tables, broken images), and binary PDF inspection.

## Why Agents Use This API Instead of DIY
Eliminates heavyweight headless Chromium containers, broken PDF byte-offset xref tables, clipped wide tables, and embarrassing 2-line trailing orphan pages before delivering client-facing PDFs.

## Connection & Payment (x402 Default + Optional Bearer API Key)
- **MCP Server (Streamable HTTP):** `https://pdf-forge.apikeg.com/mcp` (Registry ID: `com.apikeg/pdf-forge` — `initialize`, `tools/list`, `resources/*`, and `prompts/*` are free)
- **OpenAPI 3.1 Spec:** [openapi.json](https://pdf-forge.apikeg.com/openapi.json)
- **Full Schema & Examples:** [llms-full.txt](https://pdf-forge.apikeg.com/llms-full.txt)
- **RFC 9727 API Catalog:** [.well-known/api-catalog](https://pdf-forge.apikeg.com/.well-known/api-catalog)
- **x402 Bazaar Manifest:** [.well-known/x402.json](https://pdf-forge.apikeg.com/.well-known/x402.json)
- **MCP Discovery Manifest:** [.well-known/mcp.json](https://pdf-forge.apikeg.com/.well-known/mcp.json)
- **A2A Agent Card:** [.well-known/agent-card.json](https://pdf-forge.apikeg.com/.well-known/agent-card.json)
- **Primary Payment (Zero Signup):** Cloudflare Monetization Gateway (`HTTP 402` / `x402` v2 with USDC on Base).
- **Optional Monthly API Key:** Pass `Authorization: Bearer ak_live_...` ($5 / $20 / $50 monthly per-product Stripe plans at [apikeg.com/account](https://apikeg.com/account)).
- **Free Preflight:** Append `?dry_run=true` (or header `X-Dry-Run: true`) to validate any request payload at `$0.00` cost.

## Tools & REST Endpoints
- [`render_document_pdf`](https://pdf-forge.apikeg.com/tools/render-document-pdf.md) (`POST https://pdf-forge.apikeg.com/v1/render-document-pdf`) — $0.004 USD per rendered PDF document (x402 instant micropayment): Compiles Markdown (headings, bold/italic/code, lists, GFM tables, callouts, '---pagebreak---') or HTML into both print-ready themed HTML and a spec-compliant multi-page PDF 1.7 binary with running headers, 'Page X of Y' footers, repeated table headers across page breaks, optional watermark, and deterministic layoutDiagnostics.
- [`inspect_pdf_document`](https://pdf-forge.apikeg.com/tools/inspect-pdf-document.md) (`POST https://pdf-forge.apikeg.com/v1/inspect-pdf-document`) — $0.001 USD per PDF binary inspection (x402 instant micropayment): Parses a Base64-encoded PDF binary to verify %PDF header/EOF integrity and extract pdfVersion, exact pageCount, byteLength, encryption status, AcroForm presence, and Info dictionary metadata.

## Instant MCP Configuration
```json
{
  "mcpServers": {
    "pdf-forge": {
      "type": "streamable-http",
      "url": "https://pdf-forge.apikeg.com/mcp"
    }
  }
}
```

## Common Agent Use Cases
- convert markdown to PDF API for AI agents
- generate executive report or invoice PDF MCP tool
- detect trailing orphan page and wide table clipping in PDF
- pure edge HTML markdown to PDF 1.7 generator x402
- inspect PDF page count metadata encryption API
