agentsvc.io

services / html-to-pdf

visualoperational · 1136 ms

HTML to PDF

Render a URL or raw HTML string to PDF. Returns pdf_base64 (base64 PDF — decode to get raw bytes) and page_count. Provide url OR html — never both. Supports format (A4/Letter/Legal), landscape boolean, and margin settings (top/bottom/left/right in CSS units). Use for invoices, reports, or printable document generation.

Run free trial ↗1 free call per day with the example input. Paid: $0.008 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/html-to-pdf", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"html":"<h1>Invoice #123</h1><p>Total: $42.00</p>"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription

Output

FieldTypeDescription
pdf_base64stringBase64-encoded PDF bytes (decode to get raw PDF file)
page_countintegerNumber of pages in the generated PDF
file_size_bytesintegerSize of the PDF in bytes
generated_atstringISO 8601 timestamp of generation

Example response (data)

{
  "pdf_base64": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9...",
  "page_count": 2,
  "file_size_bytes": 14867,
  "generated_at": "2026-04-07T12:00:00.000Z"
}