gravityflowpdf_content

Introduction

The gravityflowpdf_content filter is used to modify the contents the PDF Generator add-on defines via the step settings template before generating the PDF. 

Parameters

ParameterTypeDefinition
$bodyArrayThe markup the template from step settings produced with current entry values.
$file_pathArrayWhere the PDF will be generated upon successful completion of the step.
$entryArrayThe current entry array.
$stepStepThe current step.

Examples

Add a custom heading above the PDF template content

add_filter( 'gravityflowpdf_content', 'sh_pdf_content_modify', 10, 4 );
function sh_pdf_content_modify( $body, $file_path, $entry, $step ) {
    $body = '<h1>Inserting a custom title before template content</h1>' . $body;
    return $body;
}

Prevent the {all_fields} merge tag from shrinking all the text in the table for long tables.

add_filter( 'gravityflowpdf_content', 'sh_pdf_content_modify', 10, 4 );
function sh_pdf_content_modify( $body, $file_path, $entry, $step ) {
    $body = str_replace( '<table width="99%" border="0" cellpadding="1" cellspacing="0" bgcolor="#EAEAEA"><tr><td>', '', $body );
    	$body = str_replace( "</td>\r\n                   </tr>\r\n               </table>", '', $body );

    	return $body;
    return $body;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?