Different footer for first page of PDF - PDF generation using HTMLTOPDF OOTB activity

I have a requirement to set different footer message for the 1st page and different footer for the remaining pages of PDF.

I am using HTMLTOPDF OOTB activity to generate PDF from Correspondence rule(which consists of HTML code).

Is there any way to set different footer(messages) across pages using HTMLTOPDF activity..?

Could any one please suggest something else..OR

confirm (no way of providing different footers across pages of PDF) from PEGA side.

Note: We are using Pega 7.1.9 version


Anupama P

***Updated by moderator: Lochan to add Categories***

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.


Keep up to date on this post and subscribe to comments

May 30, 2017 - 9:24pm

Hi Anupama, 

Thanks for posting your query on PSC :)

Technical perspective, Pega uses PDML4.jar to convert the HTML Markup to PDF (This is the basic thing happens in the background). Considering your business requirement, request you to design the HTML fragment as per your need and pass the markup to HTMLTOPDF activity. This is the way system has been designed, there is no automotive way to reach your requirement. 

Best regards,

May 30, 2017 - 9:54pm

You can try this. Create two different PDFs, One with footer and other without footer and concatenate them

May 31, 2017 - 6:50am

Thanks for your suggestions,

In my requirement, PDF content  is not static one. Content may change dynamically based on some properties of clipboard.

So, i can't go for creating two different PDF's with different footers.

Could any one please suggest something else..OR

confirm (no way of providing different footers across pages of PDF) from PEGA side.

June 2, 2017 - 12:12am

Hi Anupama,

We have implemented this requirement.

I will share the approach once  i ma free.




June 2, 2017 - 9:02am
Response to MahiPatil

Thank you Mahesh
It will be much helpful for me, if you share the approach.

Anupama P

October 12, 2017 - 8:19am
Response to MahiPatil

Hi Mahesh,

Could you please share the approach that you have used for different footer across PDF pages.




October 12, 2017 - 11:55pm
Response to AnupamaP5564

Hi Anupama,

Please find the below HTML stream which will be used to generate the different Header and footer and it need to pass PD4ML Library  to generate the PDF



//  Code to get the PDF Page Document Count // 

  String strRelatedCase = tools.getProperty(".DUmmyProp").toString();


int index ;

String strValue;

String strValue2;


//handling null pointer exception when there are no documents for the Application.


    index = 0;


    index = Integer.parseInt(strRelatedCase);   



index= index + 1;


strValue ="2-"+ index;


index = index+ 1;


strValue2 = index + "+";






<pd4ml:page.header pagesToSkip='0' areaHeight='180' scope='1'>

<pega:include name = "Header Corr Name"  type="Rule-Obj-Corr" />




<pd4ml:page.footer pagesToSkip='0' areaHeight='250' scope='1'>

   <pega:include name = "Footer Corr name "  type= "Rule-Obj-Corr" />














  <pd4ml:page.header pagesToSkip='1' areaHeight='-1'>  



<pd4ml:page.footer pagesToSkip='1' areaHeight='-1' scope=<%=strValue%>>

  <p align="center"><span style="font-size:10px;"> <span style="font-family: verdana,geneva,sans-serif;">Page $[page]</span> </span></p>





  <pd4ml:page.footer pagesToSkip='1' areaHeight='-1' scope=<%=strValue2%>>

    <p align="center"><span style="font-size:10px;"><span style="font-family: verdana,geneva,sans-serif;">Page $[page] </span></span></p>




   // Add the PDF contnet here in HTML FOrmat 









October 12, 2017 - 11:57pm
Response to MahiPatil

Java Code to Generate PDF :

String sContent=sHtml;
org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();

pd4ml.setPageInsetsMM(new java.awt.Insets(10, 21, 0, 16));
pd4ml.enableImgSplit(false); os=new; is=new; ris=new;
pd4ml.useTTF(FontsProp,false); base=new;  
pd4ml.enableDebugInfo() ;

byte[] byteArray=os.toByteArray();
       // Action == Preview
       if (Action.equalsIgnoreCase("Preview")){
              String sPDF=Base64Util.encodeToString(byteArray);
              ClipboardPage workpage = tools.findPage("pyWorkPage");
  else {

}catch(Exception e){
  throw new PRRuntimeException(e.toString());

August 7, 2018 - 5:26pm
Response to MahiPatil

Hi Mahesh,

1.what/how are you setting  JSESSIONID, PEGARULES and BASEURL strings?

2. are you able to get images to show up in your implementation?




January 31, 2018 - 4:43pm
Response to MahiPatil

Hi Mahesh,

Did you implement this using HTMLToPDF Activity? 

If so, could you provide details of how you passed this to the activity?

I am simply trying to hide the header/footer if ${page} = 1, but that is appearing like an impossible feat.



January 31, 2018 - 9:20pm
Response to KyleG173

I did not use HTMLtoPDF

June 19, 2017 - 3:49am

Please advice some ways to get it done.




July 25, 2017 - 7:58pm

I have the similar requirement. I have used PD4ML function to implement this functionality. Place the footer in the HTML stream as below. This code has to be placed before the HTML tag or immediately after the body opening.  
<pd4ml:page.footer scope="1">

 First page footer


<pd4ml:page.footer scope="2+">

Second page footer


Let me know if you have any questions.

August 24, 2017 - 7:39am
Response to NizamuddinM

Hi NizamuddinM,

I have attempted your solution, however, I did not manage to achieve the result of having different Footers for first page and the rest, nor to display footer only from the second page.

I tried the following (in both Pega Personal Edition 7.3 on Win7 and Pega 7.2 on Ubuntu):

Basic Setup: Custom pxCreatePDF Activity (in order to Property-Set-HTML param.pyPDFFooterHTMLTemplate and param.skipCommit=true), called by utility shape. PDF Content fed by HTML Rule, named "PdfHtml", (generate for JSP, see below) including my Section also in this activity, assigned into param.HTMLStream.

  1. <!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
  2. <html>
  3. <title>
  4. a
  5. </title>
  6. <body>
  7. <!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
  8. <pega:include name="mypdfcontentsection" type="Rule-HTML-Section" />
  9. </body>
  10. </html>

HTML Rule, named "PdfHtmlFooter", (generate for JSP) for pyPDFFooterHTMLTemplate is:

  1. <pd4ml:page.footer scope="2+">
  2. footer content
  3. </pd4ml:page.footer>
  4. <!-- also tried adding html and body tags here with pd4ml being called outside html or inside body -->
  5. <!-- also tried using <pd4ml:footer pagesToSkip="1"> -->

I'm expecting to see 'footer content' only from page 2.

Actual behaviour:

pd4ml tags seem to make absolutely no difference (nor pd4ml:page.footer nor pd4ml:footer).

If tags are set in the PdfHtml, in the places mentioned in my comments: footer is displayed as placed in the text, before everything, once (not in footer zone). PegaPE 7.3 also displays in the Startup CMD: "Error <pd4ml:page.footer> is not recognized!" or "Error <pd4ml:footer> is not recognized!". Couldn't find the error in any logs for Pega 7.2.

If tags are set in PdfHtmlFooter, no errors as above are shown, but:

<pd4ml:footer pagesToSkip="1"> footer is displayed on all pages, regardless of tag

<pd4ml:page.footer scope="2+"> footer is not displayed at all

What am I missing?
Do you have any idea what I could further try? I'm open to suggestions.

Best Regards,



December 21, 2017 - 5:24am
Response to IstvanSz

Hi Istvan,

I am also facing the same issue, did you find any solution for this..? Please let me know

<pd4ml:footer pagesToSkip="1"> footer is displayed on all pages, regardless of tag

<pd4ml:page.footer scope="2+"> footer is not displayed at all




December 21, 2017 - 10:32am
Response to AnupamaP5564



Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page. Once created, please reply back here with the URL of the new post.

We have also sent you a private message opening up a communication channel in case you have any further questions.



Marissa | Community Moderator | Pegasystems Inc.

May 4, 2018 - 7:51am
Response to NizamuddinM

Just tried this but giving a blank footer.

Any idea how we can get this working?

May 4, 2018 - 8:07am
Response to Will Cho

Hi Will,

I see that this is an old post and also noticed you have a related post: Different correspondence footer in first PDF page

Continuing the troubleshooting on the new post is recommeded :)


Lochana | Community Moderator | Pegasystems Inc.