Page backgrounds
Control whether background images and colors are included in the rendered PDF
The include_backgrounds
parameter allows you to control whether background images and colors are included in the rendered PDF.
Overview
When rendering a webpage to PDF, you may want to control whether background elements are included. The include_backgrounds
parameter lets you toggle this behavior to optimize for different use cases.
Parameter details
Controls whether background images and colors are included in the rendered PDF
Usage
Behavior
true
: Includes all background images and colors in the rendered PDF.false
: Omits background images and colors from the rendered PDF.
Use cases
This parameter is particularly useful for:
-
Print optimization: Disable backgrounds to create PDFs optimized for printing, reducing ink usage.
-
File size reduction: Omit backgrounds to generate smaller PDF files, which can be beneficial for sharing or storage.
-
Content focus: Remove potentially distracting background elements to emphasize the main content.
Examples
Including backgrounds (default)
Excluding backgrounds
Optimized for print
This combination creates a print-optimized PDF without backgrounds, ideal for documents intended to be printed.