Render from Any Website

Convert any web page or URL into a PDF using the Posiboo API.

Render from Any Website

Generate PDFs from any publicly accessible website or web page. Perfect for creating PDFs from dynamic web content, documentation, dashboards, or reports.


Overview

The /v1/render/source endpoint accepts a URL and renders it as a PDF. This is useful when you want to capture web content without creating a custom template.


Authentication

All requests must include your API key in the x-api-key header:

bash
x-api-key: your_api_key_here

You can create and manage API keys in your dashboard.


Basic Usage

javascript
fetch("https://api.posiboo.com/v1/render/source", {
method: "POST",
headers: {
"x-api-key": "<your-api-key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
source: "https://example.com/report"
})
})
.then(response => {
if (response.status === 202) {
console.log("PDF rendering started successfully");
}
})
.catch(error => {
console.error("Error:", error);
});

Request Parameters

Required Fields

source (string) - The full URL of the web page to render as a PDF. Must be publicly accessible.

Optional Fields

settings (object) - PDF generation settings (see Advanced Settings below).


Advanced Settings

Customize the PDF output with optional settings:

javascript
{
"source": "https://example.com/report",
"settings": {
"format": "A4", // Paper size: A4, Letter, Legal, Tabloid
"orientation": "portrait", // portrait or landscape
"margin": {
"top": "20px",
"right": "20px",
"bottom": "20px",
"left": "20px"
},
"printBackground": true, // Include background colors/images
"scale": 1.0, // Scale factor (0.1 to 2.0)
"waitForSelector": ".content-loaded", // Wait for element before rendering
"waitForTimeout": 5000, // Wait timeout in milliseconds
"emulateMediaType": "screen" // screen or print
}
}

Common Settings

format (string, default: A4) - Paper format: A4, Letter, Legal, Tabloid, A3, A5

orientation (string, default: portrait) - Page orientation: portrait or landscape

printBackground (boolean, default: true) - Include CSS backgrounds and images

scale (number, default: 1.0) - Page scale factor (0.1 to 2.0)

waitForTimeout (number, default: 0) - Milliseconds to wait before rendering

waitForSelector (string) - CSS selector to wait for before rendering

emulateMediaType (string, default: screen) - CSS media type: screen or print


Response

The endpoint returns HTTP 202 Accepted immediately, indicating that your PDF rendering job has been queued for processing.

bash
HTTP/1.1 202 Accepted

The PDF is rendered asynchronously in the background. When it's ready, you'll receive a webhook notification (see Webhooks below).


Webhooks

When your PDF is successfully rendered, Posiboo sends a webhook event to the URL you configured in your Webhooks settings.

Webhook Payload

json
{
"event": "pdf.rendered",
"timestamp": "2024-10-01T12:00:00Z",
"data": {
"jobId": "job_xyz789abc",
"source": "https://example.com/report",
"status": "completed",
"pdfUrl": "https://cdn.posiboo.com/pdfs/xyz789.pdf",
"downloadUrl": "https://api.posiboo.com/v1/pdfs/xyz789/download",
"expiresAt": "2024-10-08T12:00:00Z",
"renderTime": 2.45,
"pageCount": 8
}
}

Webhook Events

pdf.rendered - PDF was successfully generated and is ready for download.

pdf.failed - PDF rendering failed (includes error details and reason).

Configure your webhook endpoint in the Webhooks section of your dashboard.


Use Cases

Documentation Export

Convert documentation websites to PDFs:

javascript
{
"source": "https://docs.example.com/guide",
"settings": {
"format": "A4",
"printBackground": true,
"waitForSelector": ".docs-content"
}
}

Dashboard Reports

Capture dashboards or analytics pages:

javascript
{
"source": "https://app.example.com/dashboard?report=monthly",
"settings": {
"format": "Letter",
"orientation": "landscape",
"waitForTimeout": 3000,
"scale": 0.9
}
}

Dynamic Content

Render pages with JavaScript-generated content:

javascript
{
"source": "https://example.com/chart",
"settings": {
"waitForSelector": "#chart-loaded",
"waitForTimeout": 5000,
"emulateMediaType": "screen"
}
}

Error Handling

202 - Success - PDF rendering has been queued

400 - Bad Request - Missing or invalid source URL

401 - Unauthorized - Invalid or missing API key

403 - Forbidden - URL is not accessible or blocked

429 - Too Many Requests - Rate limit exceeded

500 - Server Error - Contact support

Common webhook failure reasons:

  • URL not accessible: The source URL returned 404 or is behind authentication
  • Timeout: Page took too long to load or selector was not found
  • Invalid URL: Malformed URL or unsupported protocol

Limitations

  1. Public URLs Only - The source URL must be publicly accessible without authentication
  2. Timeout Limit - Pages must load within 30 seconds (including waitForTimeout)
  3. File Size - Rendered PDFs must be under 50MB
  4. Same Rate Limits - Subject to the same rate limits as template rendering

Tips for Best Results

  1. Wait for Content - Use waitForSelector for pages with dynamic content
  2. Optimize Load Time - Ensure your source page loads quickly
  3. Test Media Types - Try both screen and print media types to see which looks better
  4. Scale for Fit - Use scale to fit wide content on standard paper sizes
  5. Include Backgrounds - Enable printBackground for better visual fidelity

Security Considerations

  • Only render URLs you trust
  • Be aware that Posiboo servers will access and render the URL
  • Don't send sensitive data in query parameters (use templates with data payloads instead)
  • URLs may be logged for debugging purposes

Next Steps