HTML to PDF API
Published: 2024-06-26 06:11:40

# HTML to PDF API

![HTML to PDF API](https://cdn.gugudata.io/api-covers%2Fapi-covers_api_cover_html2pdf.jpg)

## Overview
**API Name:** HTML to PDF  
**API URL Path:** `/v1/imagerecognition/html2pdf`  
**Request Method:** POST  
**Description:** Supports converting web pages to PDF  
**Test URL:** [API Demo](https://api.gugudata.io/v1/imagerecognition/html2pdf/demo)  
**Category:** Image Recognition  
**Tags:** Web Tool, File Processing, PDF  

## Features
- Superior performance conversion efficiency
- Supports converting passed HTML to PDF, supports converting CSS format in HTML
- Supports passing website URL, directly converting page to corresponding PDF file
- The converted PDF provides a permanent storage file address
- Full interface supports HTTPS (TLS v1.0 / v1.1 / v1.2 / v1.3)
- Fully compatible with Apple ATS
- National multi-node CDN deployment
- Interface response is extremely fast, and multiple servers build API interface load balancing

## Request Parameters

| Parameter    | Type   | Required | Default       | Description                                                                                                                                                     |
|--------------|--------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `appkey`     | string | true     | YOUR_APPKEY   | APPKEY obtained after payment                                                                                                                                   |
| `type`       | string | true     | YOUR_VALUE    | Optional parameters are HTML or URL (Note: when the type is URL, ensure that the page can be requested normally. Our interface does not handle requests for encrypted pages, anti-crawling pages, etc., that cannot return HTML normally) |
| `content`    | string | true     | YOUR_VALUE    | Content body. If type=HTML, pass HTML content; if type=URL, pass the URL of the site to be stored as a PDF                                                      |
| `landscape`  | int    | false    | 0             | Controls whether the generated PDF is in landscape page mode. Pass 1 to control landscape rendering mode, default is 0                                           |

## Return Parameters

| Parameter                         | Type   | Required | Default  | Description                                           |
|-----------------------------------|--------|----------|----------|-------------------------------------------------------|
| `DataStatus.StatusCode`           | int    | true     | N/A      | Interface return status code                          |
| `DataStatus.StatusDescription`    | string | true     | N/A      | Interface return status description                   |
| `DataStatus.ResponseDateTime`     | string | true     | N/A      | Interface data return time                            |
| `DataStatus.DataTotalCount`       | int    | true     | N/A      | Total data volume under this condition, generally used for pagination calculation |
| `Data`                            | string | true     | 0        | Permanent link to the converted PDF                   |

## Error Codes

| Error Code | Error Content                | Remark                                                            |
|------------|------------------------------|-------------------------------------------------------------------|
| 100        | Normal return                |                                                                   |
| 101        | Parameter error              |                                                                   |
| 102        | Request frequency limited    | Cannot exceed 100 requests per second                             |
| 103        | Account overdue              |                                                                   |
| 104        | Incorrect APPKEY             | Please check if the passed APPKEY is the value obtained from the developer center |
| 110        | Interface response error     |                                                                   |

## Additional Information
- **Free:** No
- **Authorization Required:** No
- **Usage Type:** 0
- **Call Count:** 0
- **Display Update Date:** No
- **Creation Date:** May 13, 2021

For more details, visit our [official website](https://gugudata.io/).