# HTML/URL to PDF
Convert HTML or public webpages into downloadable PDF files.
## API Overview
- **HTTP Protocol:** HTTPS
- **HTTP Method:** POST
- **HTTP Endpoint:** https://api.gugudata.io/v1/imagerecognition/html2pdf
- **Response Type:** application/json; charset=utf-8
- **DEMO Endpoint:** https://api.gugudata.io/v1/imagerecognition/html2pdf/demo
- **Live Demo:** https://gugudata.io/demo/html2pdf
- **Postman:** https://www.postman.com/gugudata/gugudata-io
- **LLM Page:** https://gugudata.io/details/html2pdf/llm
- **Raw Markdown:** https://gugudata.io/details/html2pdf/llm.md
## Remote MCP
- **MCP Endpoint:** https://mcp.gugudata.io/mcp
- **MCP Guide:** https://gugudata.io/mcp/
- **Authorization:** OAuth authorization opens in the browser; do not paste appkeys into MCP clients.
- **Tool Scope:** MCP clients receive GuGuData API tools available to the authorized account.
## Data & API Features
- HTML and webpage input: Create a PDF from application-generated HTML or from a complete public HTTP(S) webpage URL.
- Portrait or landscape A4 output: Choose the page orientation that best fits reports, tables, forms, and printable records.
- Styled document rendering: Preserve supported HTML, CSS, and page backgrounds for presentation-ready output.
- Downloadable HTTPS file: Receive a public PDF URL that applications can download, store, share, or attach to another workflow.
- Business document generation: Produce invoices, receipts, statements, reports, confirmations, and approval documents.
- Webpage archiving: Capture public pages as fixed-layout PDF records for review, compliance, and historical reference.
## API Request Parameters
| Name | Type | Is Required | Default Value | Remark |
| --- | --- | --- | --- | --- |
| appkey | string | true | YOUR_APPKEY | API key used to authenticate the request. |
| type | string | true | html | Input type: html for raw HTML or url for a public webpage. |
| content | string | true | <html><body><h1>Quarterly report</h1></body></html> | Raw HTML up to 5 MiB, or a complete public HTTP or HTTPS URL up to 2,048 characters. |
| landscape | integer | false | 0 | Set to 1 for landscape orientation or 0 for portrait orientation. |
## API Response Parameters
| Name | Type | Remark |
| --- | --- | --- |
| pdfPath | string | Public HTTPS URL of the generated PDF file. |
## API Response Status Codes
| Status Code | Explanation of Status Code | Remarks |
| --- | --- | --- |
| 200 | Request processed successfully. | Some endpoints expose a separate application-level status field in the response body, such as `dataStatus.statusCode`. |
| 400 | Invalid request parameters or request format. | Check required fields, data types, and request body format. |
| 401 | Missing or unknown application key. | Provide a valid `appkey` with the request. |
| 403 | The application key is recognized but access is not allowed. | The key may be expired, inactive, or not permitted for the requested API. |
| 429 | Request rate or trial usage limit exceeded. | Reduce request frequency and retry with backoff. If a trial allowance is exhausted, check Trial Keys for remaining requests and subscribe to continue. |
| 500 | Internal service error. | Retry later or contact support if the error persists. |
| 503 | Upstream service unavailable. | Retry later; the requested upstream dependency is temporarily unavailable. |
## cURL Example
```bash
curl --location 'https://api.gugudata.io/v1/imagerecognition/html2pdf?appkey=YOUR_APPKEY' --request POST --header 'Content-Type: application/json' --data '{
"type": "html",
"content": "<html><body><h1>Quarterly report</h1></body></html>",
"landscape": 0
}'
```