Generating HTML Blocks on a PDF


Looking to generate a PDF of form entries after submission, but I cannot display and print the HTML fields from the form.

Can this be done native? Can it be done with custom development?

Many thanks for help on either.


What are you using to generate the PDF currently? A plugin, or custom code, or have you not yet started?

HTML fields are display only, so they’re not saved in the entry. This can’t be changed.

I would recommend to reach the author of your PDF add-on for advice on how to proceed with HTML fields.

1 Like

Thanks Samuel - good information. I have reached out to both Gravity Flow to get their take, and also GravityPDF to see if they can help?

1 Like

This is more of a GravityPDF question than a Gravity Forms question. The answer is to edit the PDF template and insert the HTML there between the dynamic fields coming from the form input.

Thanks tugmariner.

This is extremely helpful. I have reached out to GravityPDF so hopefully can work it out with them.

Appreciate the steer for my conversation with them.

1 Like

For those who might be reading after the fact and looking for a similar solution, there are two that will work very easily with Gravity Flow PDF generator (and likely other tools/situations).

add_filter( 'gravityflowpdf_content', 'sh_pdf_content_modify', 10, 4 );
function sh_pdf_content_modify( $body, $file_path, $entry, $step ) {
	$form = GFAPI::get_form( $entry['form_id'] );
	foreach( $form['fields'] as &$field ){
		if ($field->type == 'html'){
			$content = GFCommon::replace_variables( $field->content, $form, $entry, false, true, false, 'html' );
    return $content.$body;
  • Or a similar approach but based off creating a custom merge tag that would let you place the html field(s) wherever you need within the PDF content. This snippet is similar to the one above, but could be customized to add a modifier to accept the field ID you want to display only.
add_filter( 'gform_replace_merge_tags', 'replace_html_field_tag', 10, 7 );
function replace_html_field_tag( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {

	$custom_merge_tag = '{html_fields}';

	if ( strpos( $text, $custom_merge_tag ) === false ) {
		return $text;

	$text = '';

	foreach ( $form['fields'] as &$field ) {
		if ( $field->type == 'html' ) {
			$text .= GFCommon::get_field_input( $field, '', 0, $form['id'], $form ) . '<br/><br/><br/>';
	return $text;

1 Like