# Generating HTML Blocks on a PDF

**URL:** <https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707>\
**Category:** Get Help\
**Tags:** pdf, gravity-flow\
**Created:** [January 25, 2022, 9:36am UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707 "2022-01-25T09:36:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![user612f814e6186a817](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@user612f814e6186a817](https://community.gravityforms.com/u/user612f814e6186a817)\
**Post date:** [January 25, 2022, 9:36am UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/1 "2022-01-25T09:36:24Z")

</div>

Hi

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.

Asa

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [January 25, 2022, 2:55pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/2 "2022-01-25T14:55:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sacom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sacom/32/53_2.png) [@sacom](https://community.gravityforms.com/u/sacom)\
**Post date:** [January 25, 2022, 2:56pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/3 "2022-01-25T14:56:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![user612f814e6186a817](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@user612f814e6186a817](https://community.gravityforms.com/u/user612f814e6186a817)\
**Post date:** [January 25, 2022, 4:22pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/4 "2022-01-25T16:22:06Z")

</div>

![](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/7/7e860363841b46092525e08b523d107f72a42628.png)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?

---

<div class="post-metadata">

**Author:** ![tugmariner](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/tugmariner/32/4465_2.png) [@tugmariner](https://community.gravityforms.com/u/tugmariner)\
**Post date:** [January 25, 2022, 9:18pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/5 "2022-01-25T21:18:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![user612f814e6186a817](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@user612f814e6186a817](https://community.gravityforms.com/u/user612f814e6186a817)\
**Post date:** [January 25, 2022, 9:31pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/6 "2022-01-25T21:31:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [January 26, 2022, 4:04pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/7 "2022-01-26T16:04:54Z")

</div>

Closed on January 26, 2022, 4:04pm UTC



---

<div class="post-metadata">

**Author:** ![JamieO](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/jamieo/32/2521_2.png) [@JamieO](https://community.gravityforms.com/u/JamieO)\
**Post date:** [January 28, 2022, 10:05pm UTC](https://community.gravityforms.com/t/generating-html-blocks-on-a-pdf/11707/8 "2022-01-28T22:05:54Z")

</div>

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](https://gravityflow.io/downloads/pdf-generator/) (and likely other tools/situations).

- Through the [gravityflowpdf\_content](https://gravityflow.io/docs/?d=/article/265-gravityflowpdfcontent) filter

```auto
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](https://docs.gravityforms.com/gform_replace_merge_tags/#1-replace-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.

```auto
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/>';
			break;
		}
	}
	return $text;
}

```

​
