Support Article
Unable to download a PDF multiple times
SA-88885
Summary
User creates a PDF using Rule-HTML and configures onClick of button to view it. The user is able to view the PDF on button click for the first time. However, the user is unable to view the PDF on subsequent clicks.
Error Messages
Not Applicable
Steps to Reproduce
- Create a Rule-HTML and keep it on the User Interface (UI)
- Invoke the Rule-HTML during an activity using the HTMLtoPDF activity
- Invoke the code-pega-pdf.View activity to view it
- Configure an activity which contains the above steps on a button with onClick refresh this section
- Click the button multiple times
Root Cause
A defect in Pegasystems’ code or rules.
Resolution
Perform the following local-change:
1) Add the below script to the UserWorkForm:
<script>
function downloadFile(streamName){
var suURL = SafeURL_createFromURL(pega.u.d.url);
suURL.put("pyActivity", "pyViewAsPDF");
suURL.put("pyClassName", "@baseclass");
suURL.put('ApplicationName',"XYZ");
/* suURL.put('FileName', "DecisionMemo");*/
suURL.put('FileType', "pdf");
suURL.put('HTMLStream', streamName);
suURL.put('PDFName', "PDFName");
suURL.put('SectionName', "SectionName");
var formEle = document.createElement('form');
formEle.id = "download_file";
formEle.method = "POST";
formEle.action = suURL.toURL();
if(pega.env.ua.webkit)
formEle.target = "_target";
document.body.appendChild(formEle);
formEle.submit();
document.body.removeChild(formEle);
}
</script>
2) On button click, configure the runScript action to run the above script by passing the streamName parameter to the downloadFile Javascript function since the stream value is a dynamic value which changes on selecting radio button
Published October 12, 2019 - Updated December 2, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.