Purpose
Enable external plugins or custom logic to make final modifications to the PDF generation response. This includes changes to the filename or other response parameters.
Usage
add_filter( "wr_pdf_template_modify_response", array( $this, "custom_filename" ), 10, 3 );
Parameters
-
$response (array): An associative array containing:
- “filename” (string): The name of the generated PDF file.
- “pdf” (string): The PDF content as a string.
-
$payload (array): The data associated with the template request.
-
$pdfObject (GetPdfObject): The object responsible for generating the PDF.
Use Case
This functionality is useful when:
- You need to dynamically adjust the filename or other response parameters based on specific conditions.
- Final adjustments to the response are required before the file is returned or saved.
Implementation Example
add_filter( "wr_pdf_template_modify_response", array( $this, "custom_filename" ), 10, 3 );
public function custom_filename( $response, $payload, GetPdfObject ) {
if ( $payload["option"]["identifier"] == "identifier" ) {
$response["filename"] = "custom.pdf"
}
return $filename;
}