Question


SedgwickCMS
US
Last activity: 4 Oct 2018 11:08 EDT
Generate pdf dynamically with specific values from Pega UI. Can we genearate a New PDF file from Pega without Uploading Template in eForm rule which we create to generate PDF files.
We have a requirement where
1. We need to generate the PDF dynamically with user specific values from Pega UI to be in PDF
2. If there 100 data elements in Pega UI, user have the flexibility to choose specific data elements which should be part of PDF doc
2. Attach it to the work obeject.
Can we genearate a New PDF file from Pega without Uploading Template in eForm rule which we create to generate PDF files.
Please share how it can be achieved in Pega.
**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)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution


Pegasystems Inc.
GB
Here's a more illustrated example of how to do this:
1. I am using PRPC Data Page here: just for ease of generating some data (I just took the data from Wikipedia - used EXCEL to format as CSV and then used the handy (but a bit fussy) 'Import CSV' function to import the record data)
[ Chemical element - Wikipedia, the free encyclopedia ]
2. I created my own HTML rule to directly access this data on the 'D_Chemlist' page :
Here's the HTML itself:
Here's a more illustrated example of how to do this:
1. I am using PRPC Data Page here: just for ease of generating some data (I just took the data from Wikipedia - used EXCEL to format as CSV and then used the handy (but a bit fussy) 'Import CSV' function to import the record data)
[ Chemical element - Wikipedia, the free encyclopedia ]
2. I created my own HTML rule to directly access this data on the 'D_Chemlist' page :
Here's the HTML itself:
<html> <head> <style type="text/css"> table, th, td { border: 1px solid black; } </style> </head> <body> <table> <tr> <th>Name</th> <th>AtomicNumber</th> <th>Block</th> <th>Description</th> <th>Group</th> <th>Occurrence</th> <th>Period</th> <th>State at STP</th> <th>Symbol</th> </tr> <pega:forEach name="D_ChemList.pxResults"> <tr> <td><p:r n="$THIS.Name" m="literal"/></td> <td><p:r n="$THIS.AtomicNumber" m="literal"/></td> <td><p:r n="$THIS.Block" m="literal"/></td> <td><p:r n="$THIS.Description" m="literal"/></td> <td><p:r n="$THIS.Group" m="literal"/></td> <td><p:r n="$THIS.Occurrence" m="literal"/></td> <td><p:r n="$THIS.Period" m="literal"/></td> <td><p:r n="$THIS.State_at_STP" m="literal"/></td> <td><p:r n="$THIS.Symbol" m="literal"/></td> </tr> </pega:forEach> </table> </body> </html>
To test the HTM rule: I just hit preview (this will work because the input PAGE is already built and available):
Now we can convert this to PDF using a 'wrapper' activity - and then use the 'Code-Pega-PDF' activities to VIEW it (for testing) and then finally to attach it to an existing work item.
[Note: I have setup defaults params here: and that includes a InsHandle (mentioned later) - this will be different on your system]
Note: I'm using the option "Pass current parameter page" here for both calls to HTMLTOPDF and VIEW - and then I have created 'shadow' parameters for what I need on the wrapper activities PARAMETER itself.
This just makes thing a little easier (in my view) to put together.
First we test that we can generate the PDF - and just download it (no attaching going on here yet).
We have a param (ready for attachToWork) called 'InsHandle' : but we are not yet using it : leave it blank.
The PDF is created and can be viewed:
Great.
Now we need a Work Item to test with: I just logged into a User Portal and created one:
So we make a note of it's WORK ID (M-49) - so we can use it as the "InsHandle" for our Activity.
My Work Pool is "AT-TESTATTACH-WORK" - so we combine that with the specific work item to get the InsHandle we want : "AT-TESTATTACH-WORK M-49"
We modify our activity and change the VIEW call to AttachToWork (and add the default param in for InsHandle for convenience):
And re-run it : this time we do need an InsHandle.
This time, no PDF is downloaded from the BROWSER : instead we just get the standard 'Status: good' message:
(by the way: this is what you get even if the InsHandle was incorrect, so be careful of the false positive here when testing!)
Now we go back to the User Portal : and refresh the same work item: we can see it has an attachment (or in my case , several, since I have been testing!)
Hurrah !
Attached: PDF output for example.


Pegasystems Inc.
GB
For 1,2 : you could just use the OOTB reporting mechanism (which has options for specifying criteria, filtering , sorting etc) : which allows you to 'Export to PDF'.
The PDF would need to be downloaded and attached to a Work Item manually for this though.
For 1,2,3:
You can use the OOTB Activity HTMLTOPDF:
You will probably want to arrange your data on a JSP - using Pega Tags for instance: to produce your HTML.
Then you can convert this to PDF.
The JSP tags can contain conditional logic, so you could parameterize it to alter the output dynamically.
There is an OOTB activity called "Code-Pega-PDF.AttachToWork" which will allow you to attach the PDF to a Work Item - although I confess that I haven't used this !
For reference : please view this PDN article : https://pdn.pega.com/reporting/generating-pdfs-and-attaching-them-to-work-objects-or-viewing-them-in-a-web-browser
Cheers
John
Accepted Solution


Pegasystems Inc.
GB
Here's a more illustrated example of how to do this:
1. I am using PRPC Data Page here: just for ease of generating some data (I just took the data from Wikipedia - used EXCEL to format as CSV and then used the handy (but a bit fussy) 'Import CSV' function to import the record data)
[ Chemical element - Wikipedia, the free encyclopedia ]
2. I created my own HTML rule to directly access this data on the 'D_Chemlist' page :
Here's the HTML itself:
Here's a more illustrated example of how to do this:
1. I am using PRPC Data Page here: just for ease of generating some data (I just took the data from Wikipedia - used EXCEL to format as CSV and then used the handy (but a bit fussy) 'Import CSV' function to import the record data)
[ Chemical element - Wikipedia, the free encyclopedia ]
2. I created my own HTML rule to directly access this data on the 'D_Chemlist' page :
Here's the HTML itself:
<html> <head> <style type="text/css"> table, th, td { border: 1px solid black; } </style> </head> <body> <table> <tr> <th>Name</th> <th>AtomicNumber</th> <th>Block</th> <th>Description</th> <th>Group</th> <th>Occurrence</th> <th>Period</th> <th>State at STP</th> <th>Symbol</th> </tr> <pega:forEach name="D_ChemList.pxResults"> <tr> <td><p:r n="$THIS.Name" m="literal"/></td> <td><p:r n="$THIS.AtomicNumber" m="literal"/></td> <td><p:r n="$THIS.Block" m="literal"/></td> <td><p:r n="$THIS.Description" m="literal"/></td> <td><p:r n="$THIS.Group" m="literal"/></td> <td><p:r n="$THIS.Occurrence" m="literal"/></td> <td><p:r n="$THIS.Period" m="literal"/></td> <td><p:r n="$THIS.State_at_STP" m="literal"/></td> <td><p:r n="$THIS.Symbol" m="literal"/></td> </tr> </pega:forEach> </table> </body> </html>
To test the HTM rule: I just hit preview (this will work because the input PAGE is already built and available):
Now we can convert this to PDF using a 'wrapper' activity - and then use the 'Code-Pega-PDF' activities to VIEW it (for testing) and then finally to attach it to an existing work item.
[Note: I have setup defaults params here: and that includes a InsHandle (mentioned later) - this will be different on your system]
Note: I'm using the option "Pass current parameter page" here for both calls to HTMLTOPDF and VIEW - and then I have created 'shadow' parameters for what I need on the wrapper activities PARAMETER itself.
This just makes thing a little easier (in my view) to put together.
First we test that we can generate the PDF - and just download it (no attaching going on here yet).
We have a param (ready for attachToWork) called 'InsHandle' : but we are not yet using it : leave it blank.
The PDF is created and can be viewed:
Great.
Now we need a Work Item to test with: I just logged into a User Portal and created one:
So we make a note of it's WORK ID (M-49) - so we can use it as the "InsHandle" for our Activity.
My Work Pool is "AT-TESTATTACH-WORK" - so we combine that with the specific work item to get the InsHandle we want : "AT-TESTATTACH-WORK M-49"
We modify our activity and change the VIEW call to AttachToWork (and add the default param in for InsHandle for convenience):
And re-run it : this time we do need an InsHandle.
This time, no PDF is downloaded from the BROWSER : instead we just get the standard 'Status: good' message:
(by the way: this is what you get even if the InsHandle was incorrect, so be careful of the false positive here when testing!)
Now we go back to the User Portal : and refresh the same work item: we can see it has an attachment (or in my case , several, since I have been testing!)
Hurrah !
Attached: PDF output for example.
-
Maciej Czapiewski


SedgwickCMS
US
Thanks much for detailed explaination


SmartRules
NL
Hello John,
Thanks a lot for this detailed example!
Exactly what I was looking for. Thanks!
Regards,
Ryan


Infosys
US
if we are looking for specific formatted PDF file, then OOTB functionality wont work (unless we use inline styles in section)
Approach mentioned in this article looks better since we have flexibility for formatting.


Infosys
US
what is benefit of using this approach over eForm?


Pegasystems Inc.
IN