# Html2Pdf MCP for AI Agents AI Agent Connect

> Html2Pdf lets your AI agent turn any webpage or raw HTML code into a polished PDF file instantly. You can specify page sizes, orientations, and margins while adding security features like passwords. It's built for high-quality document generation without the headache of managing your own headless browser setup.

## Overview
- **Category:** productivity
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_hqYnXrtHoxaxeAjnVe4IpLK7Mpj4ffymmSOGrfz5/ai-agent-connect
- **Tags:** pdf-generation, html-to-pdf, web-to-pdf, document-automation, reporting

## Description

You're trying to get a clean PDF out of a website or some messy HTML, and usually, that means dealing with broken layouts or manual screenshots. This Connector changes that by letting your AI client handle the heavy lifting of rendering and formatting. Instead of copy-pasting text into a word processor, you just tell your agent what you need. It can grab a live URL and turn it into a high-quality document or take a string of HTML and build something custom, like an invoice or a resume. You get full control over the details that usually break, like page margins, A4 or Letter sizing, and even specific CSS for printing. Because it handles the rendering engine for you, you don't have to worry about fonts or layout shifts. It's a core part of the Vinkius catalog, making it easy to plug into your existing workflow. You can even set up background processing for big jobs so your agent doesn't hang while waiting for a file to finish. It's about getting a professional result every time without the technical overhead of a local browser instance.

## Tools

### generate_pdf
Converts a URL or HTML string into a PDF and returns it as a base64 string or via a webhook.

## Prompt Examples

**Prompt:** 
```
Convert https://google.com to a PDF in A4 format and landscape orientation.
```

**Response:** 
```
I've started generating that PDF for you. It'll be in A4 landscape format. I'll provide the file as a base64 string as soon as it's ready.
```

**Prompt:** 
```
Generate a PDF from this HTML: '<h1>Invoice #123</h1><p>Total: $50</p>' and name it 'invoice.pdf'.
```

**Response:** 
```
Got it. I'm turning that HTML into a PDF now. I've named the file 'invoice.pdf' and it's ready for you to download.
```

**Prompt:** 
```
Create a password-protected PDF of https://example.com using 'secret123' as the password.
```

**Response:** 
```
I'm securing that document for you now. I've generated the PDF for example.com and encrypted it with the password 'secret123'.
```

## Capabilities

### Capture webpages as PDFs
Turn any live URL into a high-quality document snapshot.

### Render custom HTML
Generate documents like invoices or certificates from raw code.

### Set page dimensions
Choose between A4, Letter, and custom orientations.

### Apply security locks
Protect files with passwords and restrict copying or printing.

### Execute JavaScript
Use wait times to ensure dynamic content loads before capturing.

### Process files in the background
Use webhooks to handle large document generation tasks.

## Use Cases

### Invoice Generation
A user asks the agent to create a PDF invoice for a client using a specific HTML template.

### Web Archiving
A researcher tells the agent to save a live article as a PDF and protect it with a password.

### Report Exporting
An analyst asks the agent to turn a live dashboard URL into a landscape A4 PDF for a board meeting.

### Certificate Creation
A teacher asks the agent to generate a PDF certificate from an HTML string and name it for a student.

## Benefits

- Skip the headless browser setup: You don't need to maintain a complex server just to generate a few PDFs.
- Get pixel-perfect layouts: Use generate_pdf to ensure your CSS renders exactly how you want it on the page.
- Secure your documents: Add password protection and print restrictions directly through your AI agent's instructions.
- Handle heavy loads: Use async callbacks to process large batches of documents without blocking your agent's main thread.
- Standardize your outputs: Force every document into specific formats like A4 or Letter to keep your branding consistent.

## How It Works

The bottom line is you get professional, customizable PDFs without managing any browser infrastructure.

1. Connect your Html2Pdf API key to your AI client via the Vinkius marketplace.
2. Give your agent a URL or a block of HTML code along with your styling preferences.
3. Get back a base64 encoded PDF string or a webhook notification for large files.

## Frequently Asked Questions

**Can Html2Pdf convert a live website into a PDF?**
Yes, it can take any public URL and capture a high-quality snapshot of the page as a PDF.

**Does Html2Pdf support custom page sizes like A4 or Letter?**
Yes, you can specify the paper size and orientation like landscape during the generation process.

**Can I protect the PDFs I create with Html2Pdf?**
You can add user passwords and restrict actions like printing or copying to keep your documents secure.

**How does Html2Pdf handle large files?**
For large documents, it supports async callbacks so your agent doesn't have to wait around while the file processes.

**Can I use Html2Pdf to create invoices from custom code?**
Absolutely. You can send raw HTML strings to the Connector to generate custom documents like invoices or resumes.

**Does Html2Pdf wait for JavaScript to load?**
Yes, it supports a wait parameter to ensure that dynamic content is fully rendered before the PDF is captured.

**Can I wait for JavaScript to finish before generating the PDF?**
Yes! Use the `waitFor` parameter (up to 10 seconds) in the `generate_pdf` tool. This is ideal for pages that rely on async data loading or animations before they are ready to be captured.

**Is it possible to add custom headers and footers to the document?**
Absolutely. You can provide HTML strings for `headerTemplate` and `footerTemplate` to include page numbers, logos, or dates on every page of your generated PDF.

**Can I protect the generated PDF with a password?**
Yes. By setting the `userPassword` parameter, the server will trigger AES 128-bit encryption, requiring that password to open the document.