Invoice #INV-2026-001
| API Pro Plan | $29.00 |
| Extra Requests (5,000) | $15.00 |
| Total | $44.00 |
Hello World
This is a PDF generated from HTML.
", "format": "A4", "print_background": true }' \ --output hello.pdf ``` ### Node.js ```javascript const ToolCenter = require('devtoolbox-sdk'); const fs = require('fs'); const client = new ToolCenter('YOUR_API_KEY'); // Convert URL to PDF async function urlToPdf() { const pdf = await client.pdf({ url: 'https://example.com', format: 'A4', marginTop: '20mm', marginBottom: '20mm', marginLeft: '15mm', marginRight: '15mm', printBackground: true }); fs.writeFileSync('document.pdf', pdf); console.log('PDF generated successfully!'); } // Convert HTML template to PDF (invoice example) async function generateInvoice(invoiceData) { const html = `Invoice #${invoiceData.number}
Date: ${invoiceData.date}
| Item | Amount |
|---|---|
| ${item.name} | $${item.amount} |
| Total | $${invoiceData.total} |
Monthly Report - February 2026
Total API calls: 45,231
Success rate: 99.8%
Average response time: 1.2s
Contract
Terms and conditions...
', 'format' => 'A4', 'header_html' => 'CONFIDENTIAL
',
'footer_html' => 'Page of
',
]);
file_put_contents('contract.pdf', $pdf);
```
## Advanced Features
### Custom Headers and Footers
Add professional headers and footers to your PDFs:
```bash
curl -X POST "https://toolcenter.dev/api/v1/pdf" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"format": "A4",
"header_html": "Company Name — Confidential
",
"footer_html": "Page of
"
}' \
--output report.pdf
```
### Landscape Mode
Perfect for wide tables, charts, and dashboards:
```javascript
const pdf = await client.pdf({
url: 'https://dashboard.example.com',
format: 'A4',
landscape: true,
printBackground: true
});
```
### Custom Page Sizes
Use predefined sizes or specify custom dimensions:
```python
# Letter size (US standard)
pdf = client.pdf(url="https://example.com", format="Letter")
# Legal size
pdf = client.pdf(url="https://example.com", format="Legal")
```
## Best Practices
### 1. Use Print Stylesheets
Add a `@media print` stylesheet to your HTML for optimal PDF output:
```css
@media print {
.no-print { display: none; }
body { font-size: 12pt; }
a { text-decoration: none; color: #000; }
.page-break { page-break-after: always; }
}
```
### 2. Handle Pagination
Use CSS page break properties for multi-page documents:
```css
.section { page-break-inside: avoid; }
h2 { page-break-after: avoid; }
.chapter { page-break-before: always; }
```
### 3. Embed Fonts
For consistent rendering, use web fonts or embed fonts as base64:
```html
```
### 4. Optimize Images
Ensure images are accessible via public URLs or embed them as base64 data URIs for reliable rendering.
### 5. Test with Print Preview
Use your browser's print preview (Ctrl+P) to approximate how the PDF will look before making API calls.
## Pricing
ToolCenter PDF API is included in all plans at no extra cost:
| Plan | Price | Monthly Requests | Features |
|---|---|---|---|
| Free | $0 | 100 | All tools included |
| Starter | $9/mo | 5,000 | Priority support |
| Pro | $29/mo | 25,000 | Bulk operations, signed URLs |
| Business | $79/mo | 100,000 | Custom webhooks, SLA |
## Conclusion
Converting HTML to PDF doesn't have to be painful. With the **ToolCenter PDF API**, you can generate professional PDF documents from any URL or HTML content in seconds, without managing headless browsers or dealing with rendering inconsistencies.
The API handles the complexity of PDF generation — fonts, pagination, headers, footers, and scaling — so you can focus on building your application.
**[Get Started Free →](https://toolcenter.dev)**
---
*Need help? Check the [API documentation](https://toolcenter.dev/docs) or reach out to our support team.*