Content parts
Specify one or more content sources to render into a single PDF document
The parts
parameter allows you to define the content sources that will be rendered into your PDF document.
Overview
When generating a PDF, you need to specify what content to render. The parts
parameter accepts an array of content sources, which can be URLs, HTML strings, or structured content objects. These sources are rendered sequentially into a single PDF document.
Parameter details
Defines the content sources that will be rendered into your PDF document
Min items: 1
Max items: 50
Item types: URL string, HTML string, or content object
Usage
Behavior
The parts
parameter accepts three types of content:
- URL strings: Publicly accessible URLs that return HTML content.
- HTML strings: Raw HTML content that starts with a valid HTML tag.
- Content objects: Structured objects with
type
andcontent
fields. The content object can be:- URL content with
type: "url"
- HTML content with
type: "html"
- Template content with
type: "template"
(see the Templates page for details)
- URL content with
Each content part is rendered sequentially in the order provided, creating a multi-page PDF where each part typically starts on a new page.
Use cases
This parameter is particularly useful for:
-
Multi-source documents: Combine content from multiple webpages into a single PDF.
-
Mixed content types: Blend web content with custom HTML in the same document.
-
Report generation: Create comprehensive reports by combining dynamic web content with static templates.
-
Document assembly: Build documents from multiple components stored in different locations.
-
Dynamic content injection: Use templates with context data to generate personalized documents.
Examples
Single URL
Multiple URLs
Mixing URLs and HTML
Using structured content objects
For more details on using templates, see the Templates documentation.