Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

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

  1. Create a Rule-HTML and keep it on the User Interface (UI)
  2. Invoke the Rule-HTML during an activity using the HTMLtoPDF activity
  3. Invoke the code-pega-pdf.View activity to view it
  4. Configure an activity which contains the above steps on a button with onClick refresh this section
  5. 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

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us