Browserless icon

Browserless

Browserless API

Overview

This node interacts with the Browserless API to generate PDFs from web pages or HTML content. It is useful for automating the process of capturing web pages as PDFs with customizable options such as page format, margins, headers, footers, and more. Practical applications include generating reports, saving web content for offline viewing, or archiving web pages.

Use Case Examples

  1. Generate a PDF of a webpage by providing its URL and specifying PDF options like page size and orientation.
  2. Create a PDF from raw HTML content with custom headers and footers.
  3. Wait for specific page elements or events before generating the PDF to ensure content is fully loaded.

Properties

Name Meaning
Url The URL of the web page to convert to PDF. Required unless using custom body.
Wait For Timeout Time in milliseconds to wait before generating the PDF.
Wait For Selector CSS selector and conditions to wait for before generating the PDF.
Options PDF generation options such as scale, header/footer templates, print background, page format, margins, and more.
Goto Options Options for navigating to the URL such as referer, timeout, and waitUntil events.
Wait For Event Event and timeout to wait for before generating PDF.
Wait For Function Function to evaluate in browser context and polling options to wait for before generating PDF.
Add Script Tag JavaScript scripts to inject into the page before generating PDF.
Add Style Tag CSS styles to inject into the page before generating PDF.
Set Extra HTTP Headers Additional HTTP headers to set for the page request.
Authenticate Username and password for HTTP authentication.
Viewport Viewport settings such as width, height, device scale factor, and orientation.
Emulate Media Type Media type to emulate (e.g., screen, print).
Timeout Override system-level timeout for the request in milliseconds.
Html Raw HTML content to generate PDF from instead of URL.
User Agent User agent string to use for the page request.
Best Attempt Whether to proceed with PDF generation even if awaited events fail or timeout.
Enable Cookies Enable cookies for the session.
Cookies Array of cookie objects to set for the session.
Block Ads Whether to load ad-blocking extensions during the session.
Set Java Script Enabled Enable or disable JavaScript execution on the page.
Enable Launch Whether to launch a new browser instance.
Launch Options for launching the browser instance such as args, viewport, headless mode, and more.
Reject Resource Types Resource types to block from loading.
Reject Request Pattern Request URL patterns to block.
Request Interceptors Patterns and corresponding responses to intercept and fulfill requests.
Use Custom Body Whether to use a custom request body instead of individual parameters.
Custom Body Custom JSON body to send in the request.

Output

Binary

PDF file content in binary format if saved to a path or returned as binary data.

JSON

  • pdfUrl - URL or path to the generated PDF file.
  • pdfBase64 - Base64 encoded string of the generated PDF content.
  • status - Status of the PDF generation request.

Dependencies

  • Browserless API

Troubleshooting

  • Ensure the URL is accessible and correct to avoid navigation errors.
  • Timeouts may occur if the page takes too long to load or if waiting conditions are not met; adjust timeout settings accordingly.
  • Authentication failures if username or password are incorrect; verify credentials.
  • PDF generation options must be valid; invalid page formats or margin values may cause errors.
  • If using custom scripts or styles, ensure they do not interfere with page rendering.

Links

Discussion