# API2PDF

Api2Pdf is a REST API that enables developers to generate PDFs from HTML, URLs, and various document formats using engines like wkhtmltopdf, Headless Chrome, and LibreOffice.

- **Category:** documents
- **Auth:** API_KEY
- **Composio Managed App Available?** N/A
- **Tools:** 10
- **Triggers:** 0
- **Slug:** `API2PDF`
- **Version:** 20260227_00

## Tools

### Add Header Footer

**Slug:** `API2PDF_ADD_HEADER_FOOTER`

Convert HTML to PDF with customizable headers and footers using Headless Chrome. Use for generating reports, invoices, or documents with consistent page numbering, titles, dates, or branding on every page.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `html` | string | Yes | Raw HTML content to convert into a PDF. Must include any page structure needed. |
| `options` | object | No | Advanced options for header and footer display in the PDF. |
| `fileName` | string | No | Desired filename for the generated PDF (e.g., 'report.pdf'). If omitted, the API assigns a random name. |
| `inlinePdf` | boolean | No | If true, returns the PDF inline as base64; otherwise, returns a download URL. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Check API Status

**Slug:** `API2PDF_CHECK_STATUS`

Tool to check the health status of the API2PDF service. Use when you need to verify if the API is available and responding. This endpoint does not require authentication and returns a simple status indicator.

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Delete PDF

**Slug:** `API2PDF_DELETE_PDF`

Delete a previously generated PDF from API2PDF storage by its response ID. By default, API2PDF automatically deletes PDFs after 24 hours. Use this tool when you need to immediately remove a PDF for security or cleanup purposes. The response_id parameter is the ResponseId returned from any PDF generation operation (e.g., merge, convert HTML to PDF, etc.).

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `response_id` | string | Yes | The ResponseId returned from a previous API2PDF operation (e.g., merge, convert). This UUID identifies the PDF file to delete from API2PDF storage. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Extract PDF Pages

**Slug:** `API2PDF_EXTRACT_PAGES`

Tool to extract specific pages from a PDF document. Use when you need only certain pages from a larger PDF file. Provide a URL to the source PDF and optionally a page range (0-indexed, end exclusive). Returns a URL to the extracted PDF.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `end` | integer | No | Zero-based index of the last page to extract (exclusive). Negative values count from end. Defaults to end of document. When both start and end are 0 (or omitted), all pages are extracted. |
| `url` | string | Yes | URL of the source PDF (must start with http:// or https://). |
| `start` | integer | No | Zero-based index of the first page to extract (inclusive). Negative values count from end (-1 is last page). Defaults to 0 (first page). |
| `inline` | boolean | No | If true, returns the PDF inline; otherwise returns a download URL. Default is true. |
| `storage` | object | No | Custom storage settings for uploading the extracted PDF file. |
| `fileName` | string | No | Desired filename for the extracted PDF (e.g., 'pages.pdf'). Random name if omitted. |
| `extraHTTPHeaders` | object | No | Key-value object specifying headers when fetching the source PDF. |
| `useCustomStorage` | boolean | No | When true, upload the extracted PDF via the provided storage settings. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### LibreOffice PDF to HTML

**Slug:** `API2PDF_LIBREOFFICE_PDF_TO_HTML`

Tool to convert a PDF document to HTML using LibreOffice. Use when you need HTML output of a PDF file (experimental; images may be excluded).

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `url` | string | Yes | Direct URL to the source PDF file. |
| `inline` | boolean | No | If true, returns HTML content inline in the JSON response; otherwise returns a URL. |
| `fileName` | string | No | Desired filename for the output HTML file (e.g., 'output.html'). |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### LibreOffice Thumbnail

**Slug:** `API2PDF_LIBREOFFICE_THUMBNAIL`

Tool to generate a thumbnail image of a document using LibreOffice. Use when you need a quick visual preview of a PDF or Office file's first page.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `url` | string | Yes | Direct URL to a publicly accessible PDF or Office document (Word, Excel, PowerPoint) to generate a thumbnail from. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Merge PDFs

**Slug:** `API2PDF_MERGE_PDFS`

Merge multiple PDF documents into a single PDF file. Provide a list of publicly accessible PDF URLs, and they will be combined in the order specified. The merged PDF is available via a download URL for 24 hours.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `urls` | array | Yes | List of publicly accessible URLs pointing to PDF files to merge. The PDFs will be combined in the order they appear in this list. |
| `inline` | boolean | No | If true, open the merged PDF in the browser; otherwise force download |
| `storage` | object | No | Custom storage settings for uploading the merged PDF. |
| `fileName` | string | No | Desired filename for the merged PDF (e.g., 'output.pdf'). Random name if omitted |
| `extraHTTPHeaders` | object | No | Optional headers to use when fetching each source PDF |
| `useCustomStorage` | boolean | No | When true, upload the merged PDF via the provided storage settings |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Optimize PDF

**Slug:** `API2PDF_OPTIMIZE_PDF`

Tool to optimize a PDF document to reduce file size while maintaining quality. Use when you need to minimize storage or bandwidth for an existing PDF.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `url` | string | Yes | URL of the PDF file to optimize. Must start with http:// or https:// |
| `inline` | boolean | No | If true, open the optimized PDF in a browser window. Defaults to True. |
| `storage` | object | No | Custom storage options: method, url, extraHTTPHeaders. Required if useCustomStorage is true. |
| `fileName` | string | No | Filename for the output PDF. Random name if omitted. |
| `extraHTTPHeaders` | object | No | Headers to include when fetching the source PDF. |
| `useCustomStorage` | boolean | No | Whether to use custom storage options (see `storage`). Defaults to False. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Reorder PDF Pages

**Slug:** `API2PDF_REORDER_PAGES`

Reorder pages of a PDF document by specifying a new page sequence. Provide a URL to the source PDF and a list of zero-based page indices in the desired order. For example, to reverse a 3-page PDF, use pages=[2,1,0]. The reordered PDF is available via a download URL for 24 hours.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `url` | string | Yes | URL of the source PDF to reorder (must start with http:// or https://). |
| `pages` | array | Yes | List of zero-based page indices defining the new order. For example, [2,0,1] reorders a 3-page PDF to show page 3, then page 1, then page 2. Each index must be valid for the source PDF. |
| `inline` | boolean | No | If true, returns the PDF inline; otherwise returns a download URL. |
| `storage` | object | No | Custom storage settings for uploading the PDF file. |
| `fileName` | string | No | Desired filename for the reordered PDF (e.g., 'reordered.pdf'). Random name if omitted. |
| `extraHTTPHeaders` | object | No | Key-value headers when fetching the source PDF. |
| `useCustomStorage` | boolean | No | When true, upload the final PDF via provided storage settings. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Generate Barcode or QR Code

**Slug:** `API2PDF_ZEBRA_GENERATE_BARCODE`

Tool to generate barcodes or QR codes using Zebra Crossing (ZXING). Use when you need a barcode or QR code image from text values.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `value` | string | Yes | The text or data value to encode in the barcode. For 1D barcodes, this is typically alphanumeric. For QR codes, can include URLs, text, or other data. |
| `width` | integer | No | Width of the generated barcode image in pixels. If not specified, uses the API default. |
| `format` | string | Yes | Barcode format to generate. Supported 1D formats: CODABAR, CODE_39, CODE_93, CODE_128, EAN_8, EAN_13, ITF, RSS_14, RSS_EXPANDED, UPC_A, UPC_E, UPC_EAN_EXTENSION. Supported 2D formats: AZTEC, DATA_MATRIX, MAXICODE, PDF_417, QR_CODE. Most commonly used: QR_CODE (for 2D) or CODE_128 (for 1D). |
| `height` | integer | No | Height of the generated barcode image in pixels. If not specified, uses the API default. |
| `showlabel` | boolean | No | When true, displays the human-readable text value below the barcode image. API default is false. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |
