> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spoolpdf.nandra.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# HTML to PDF

> Send HTML you already have. Fastest path and no SSRF check.

Use this when you already have HTML (invoice, receipt, Blade, a template). Prefer it over URL render.

```bash theme={null}
curl -sS -D - -o invoice.pdf \
  -X POST "$SPOOLPDF_BASE_URL/v1/render" \
  -H "Authorization: Bearer $SPOOLPDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Invoice #1001</h1><p>Total: $42.00</p>",
    "format": "A4",
    "print_background": true
  }'
```

Success: `200`, `application/pdf`, `X-Request-Id`, `X-Usage-Count` (omitted when `sandbox` is true).

<CodeGroup>
  ```javascript Node theme={null}
  import { SpoolPdfClient } from "@spoolpdf/sdk-node";
  const client = new SpoolPdfClient({ apiKey: process.env.SPOOLPDF_API_KEY });
  const pdf = await client.render({
    html: "<h1>Invoice #1001</h1>",
    format: "A4",
    print_background: true,
  });
  ```

  ```php PHP theme={null}
  $pdf = (new Spoolpdf\Sdk\Client(getenv('SPOOLPDF_API_KEY')))->render([
      'html' => '<h1>Invoice #1001</h1>',
      'format' => 'A4',
      'print_background' => true,
  ]);
  ```
</CodeGroup>

See [layout](/guides/layout) for margins and headers, [sandbox](/guides/sandbox) for an unmetered preview, and [POST /v1/render](/api-reference/overview).
