# Section embedded in paragraph rule for generating PDF doesnot get same formatting of section

**URL:** <https://forums.pega.com/t/section-embedded-in-paragraph-rule-for-generating-pdf-doesnot-get-same-formatting-of-section/8632>\
**Category:** Knowledge Share\
**Tags:** 8-8-5, user-experience, pega-platform\
**Created:** [November 18, 2024, 8:35pm UTC](https://forums.pega.com/t/section-embedded-in-paragraph-rule-for-generating-pdf-doesnot-get-same-formatting-of-section/8632 "2024-11-18T20:35:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavanir6](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Pavanir6](https://forums.pega.com/u/Pavanir6)\
**Post date:** [November 18, 2024, 8:35pm UTC](https://forums.pega.com/t/section-embedded-in-paragraph-rule-for-generating-pdf-doesnot-get-same-formatting-of-section/8632/1 "2024-11-18T20:35:10Z")

</div>

Below are the steps to generate a Pdf where we will embed a section as input , and to get exact UI formatting of section in PDF.

Create a HTML rule as below

  

```auto
<pega:include name="sectionxxxx" type="Rule-HTML-Section" />

<br />

  <pega:include name="sectionyyy" type="Rule-HTML-Section" />

<br />

  <pega:include name="sectionzzz" type="Rule-HTML-Section" />

  

</head>

```

 this gives exact styling in pdf as in section.

Now create a activity

step -1 property set

Param.FileName=“yyyy.pdf”

step -2 call pyViewAsPDF

HTMLSTREAM=above html rule name

PDFName= Param.filename

Now call it in section on any button with on click open url in new window-give activity name

window name parameter should be as “\_self” (Quotes not required).

---

<div class="post-metadata">

**Author:** ![Sairohith](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/sairohith/32/23362_2.png) [@Sairohith](https://forums.pega.com/u/Sairohith)\
**Post date:** [April 13, 2026, 3:19am UTC](https://forums.pega.com/t/section-embedded-in-paragraph-rule-for-generating-pdf-doesnot-get-same-formatting-of-section/8632/2 "2026-04-13T03:19:08Z")

</div>

HTML rule to include the required sections with the `pega:include` tag, because this keeps the same section styling in the generated PDF. Add each section in that HTML rule in the order you want them to appear. Then create an activity that first sets `Param.FileName` to the PDF name. In the next step, call `pyViewAsPDF` and pass the HTML rule name in `HTMLSTREAM` and the file name in `PDFName`. Finally, call this activity from the button using `Open URL in new window` and set the window name to `_self`. This generates the PDF with the same formatting as the original sections.
