Purpose
Overwrite the CSS used in the PDF template programmatically. This filter allows external plugins or custom logic to dynamically adjust the CSS styling for specific PDF templates.
Usage
add_filter( "wr_pdf_template_container_css", array( $this, "get_pdf_template_container_css" ), 10, 4 );
Parameters
$css (string)
: The current CSS applied to the PDF template.$options (array)
: An array of options associated with the PDF template, such as identifiers or configuration settings.$payload (array)
: The data associated with the template request.
Use Case
This functionality is useful when:
- You need to apply specific CSS styles to PDFs generated from particular templates.
- Dynamic adjustments to the PDF’s styling are required based on the template’s identifier or context.
Implementation Example
The following example sets custom CSS for a PDF template identified by pdf_identifier
:
add_filter( "wr_pdf_template_container_css", array( $this, "get_pdf_template_container_css" ), 10, 4 );
public function get_pdf_template_container_css( $css, $options, $payload ) {
// Filter PDF Template Identifier
if($option["identifier"]=="pdf_identifier") {
$css = "YOUR CUSTOM CSS";
}
return $css;
}