Question


CapGemini
IN
Last activity: 16 Oct 2018 12:03 EDT
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
Thanks
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.
-
Like (0)
Simen Fredrik Brunvand Fredriksen -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!


Vodafone
IN
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.
Thanks,
Best regards,
Naveen


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


CapGemini
IN
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.


ANZ Banking Group Ltd
AU
Hi Anupama,
We have implemented this requirement.
I will share the approach once i ma free.
Thanks,
Mahesh


CapGemini
IN


CapGemini
IN
Hi Mahesh,
Could you please share the approach that you have used for different footer across PDF pages.
Thanks
Anupama


ANZ Banking Group Ltd
AU
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
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


ANZ Banking Group Ltd
AU
Java Code to Generate PDF :
try{
String sContent=sHtml;
org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();
//pd4ml.resetAddedStyles();
pd4ml.setPageInsetsMM(new java.awt.Insets(10, 21, 0, 16));
pd4ml.enableImgSplit(false);
java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
java.io.InputStream is=new java.io.ByteArrayInputStream(sContent.getBytes());
java.io.InputStreamReader ris=new java.io.InputStreamReader(is);
pd4ml.setCookie("JSESSIONID",JSESSIONID);
pd4ml.setCookie("Pega-RULES",PEGARULES);
pd4ml.useTTF(FontsProp,false);
java.net.URL base=new java.net.URL(BASEURL);
pd4ml.enableDebugInfo() ;
pd4ml.protectPhysicalUnitDimensions();
pd4ml.render(ris,os,base);
byte[] byteArray=os.toByteArray();
// Action == Preview
if (Action.equalsIgnoreCase("Preview")){
String sPDF=Base64Util.encodeToString(byteArray);
ClipboardPage workpage = tools.findPage("pyWorkPage");
workpage.putString("PDFDocument",sPDF);
}
else {
tools.putParamValue("PDFDocument",byteArray);
}
Java Code to Generate PDF :
try{
String sContent=sHtml;
org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();
//pd4ml.resetAddedStyles();
pd4ml.setPageInsetsMM(new java.awt.Insets(10, 21, 0, 16));
pd4ml.enableImgSplit(false);
java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
java.io.InputStream is=new java.io.ByteArrayInputStream(sContent.getBytes());
java.io.InputStreamReader ris=new java.io.InputStreamReader(is);
pd4ml.setCookie("JSESSIONID",JSESSIONID);
pd4ml.setCookie("Pega-RULES",PEGARULES);
pd4ml.useTTF(FontsProp,false);
java.net.URL base=new java.net.URL(BASEURL);
pd4ml.enableDebugInfo() ;
pd4ml.protectPhysicalUnitDimensions();
pd4ml.render(ris,os,base);
byte[] byteArray=os.toByteArray();
// Action == Preview
if (Action.equalsIgnoreCase("Preview")){
String sPDF=Base64Util.encodeToString(byteArray);
ClipboardPage workpage = tools.findPage("pyWorkPage");
workpage.putString("PDFDocument",sPDF);
}
else {
tools.putParamValue("PDFDocument",byteArray);
}
}catch(Exception e){
throw new PRRuntimeException(e.toString());
}


Stratosphere Consulting
US
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?
THanks!


FrontierBPM
US
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.
Thanks,
Kyle


ANZ Banking Group Ltd
AU
I did not use HTMLtoPDF


CapGemini
IN
Please advice some ways to get it done.
Thanks
Anupama


Agora Group
IN
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>
<pd4ml:page.footer scope="2+">
Second page footer
</pd4ml:page.footer>
Let me know if you have any questions.


msg-systems
DE
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.
<!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
<html>
<title>
a
</title>
<body>
<!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
<pega:include name="mypdfcontentsection" type="Rule-HTML-Section" />
</body>
</html>
HTML Rule, named "PdfHtmlFooter", (generate for JSP) for pyPDFFooterHTMLTemplate is:
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.
<!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
<html>
<title>
a
</title>
<body>
<!-- tried calling pd4ml here without pyPDFFooterHTMLTemplate being set -->
<pega:include name="mypdfcontentsection" type="Rule-HTML-Section" />
</body>
</html>
HTML Rule, named "PdfHtmlFooter", (generate for JSP) for pyPDFFooterHTMLTemplate is:
<pd4ml:page.footer scope="2+">
footer content
</pd4ml:page.footer>
<!-- also tried adding html and body tags here with pd4ml being called outside html or inside body -->
<!-- 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,
Istvan


CapGemini
IN
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
Thanks
Anupama


Pegasystems Inc.
US


Pegasystems Inc.
US
Just tried this but giving a blank footer.
Any idea how we can get this working?


Pegasystems Inc.
IN
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 :)
Thanks!