Question
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Coforge
IN
Last activity: 5 Feb 2019 8:05 EST
PDF generation and download pdf to browser
Hi,
I have a requirement of generating a pdf on click of a button.
I am calling an activity on the button by refreshing the section where I use
.Property-set to set parameters
.property-set-html to pass html stream
.activity HTMLto PDF to generate pdf and
.view CODE-Pega-PDF to send the file back to user
the activity works fine for the first time whenever I click on the button and the pdf gets generated.But issue comes when I click on the button again,pdf is not being sent to user.Again it works good If reopen the case for one time
please help
***Edited by Moderator Marissa to update platform capability tags****
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689972000/160a94fb-107f-457d-9893-98ea9c84e0f0.png?itok=PDA9Ravy)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689972000/160a94fb-107f-457d-9893-98ea9c84e0f0.png?itok=PDA9Ravy)
Swiftrinity
NL
Hi Sarmishta,
Instead of running activity on "Refresh", use Open URL in Window and call activity there (with use page check box checked). This downloads PDF in new window, so there won't be any refresh problems.
Hope this helps..!!
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Coforge
IN
Thank You the reply Amar.
Used this already but the activity when used with "Open URL in New Window" is through a status error and not being run.
If any clue,please share.
and as per the requirement the document should be downloaded and user should open it
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689972000/160a94fb-107f-457d-9893-98ea9c84e0f0.png?itok=PDA9Ravy)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689972000/160a94fb-107f-457d-9893-98ea9c84e0f0.png?itok=PDA9Ravy)
Swiftrinity
NL
Sarmishta,
There must be problem with the parameters that you are passing to HTMLToPDF activity. Please check.
I followed below steps:
Step1: on button use "Open URL in New Window" to run activity with use page check box checked
Step2: In activity, pass Param.pyPDFPageOrientation as "potrait"; Param.StreamName(instead of Markup that you have used using Property-set-html method) parameters to HTMLToPDF activity
Sarmishta,
There must be problem with the parameters that you are passing to HTMLToPDF activity. Please check.
I followed below steps:
Step1: on button use "Open URL in New Window" to run activity with use page check box checked
Step2: In activity, pass Param.pyPDFPageOrientation as "potrait"; Param.StreamName(instead of Markup that you have used using Property-set-html method) parameters to HTMLToPDF activity
For Param.StreamName, you need to create HTML rule and call required section and apply css using below tags
<link rel="stylesheet" type="text/css" href="webwb/<<CSSTextFileName>>.css"/>
<pega:include name="<<SectionName>>" type="Rule-HTML-Section"/>
Step3: pass "<<RequiredPDFName>>.pdf" as parameter to Param.PDFName for .View activity
HTML rule from which section is called using
<link rel="stylesheet" type="text/css" href="webwb/GenerateCarePlanPDF.css"/>
<pega:include name="GenerateCarePlanPDF" type="Rule-HTML-Section"/>
-
Chethan Konereddy
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Coforge
IN
Amar,
Thank you for the response
Yes, the issue was that PDF name passed as null.
As per requirement New window should not be opened but working as expected with IE.
so slightly modified the requirement
Thank you again!
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
ANZ Banking Group Ltd
IN
Hi amar,
Using 'open URL in Window' is working fine for my code,but the downloaded pdf opens in adobe and extra popup down is blank.
Can we do something to avoid this blank window
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689991000/770af0a7-ff94-4955-8d57-61b50aa19967.jpg?itok=H7Z3ThoH)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689991000/770af0a7-ff94-4955-8d57-61b50aa19967.jpg?itok=H7Z3ThoH)
CPF Board
SG
Where you able to avoid blank window ? If Yes , Please help with the changes required .
-
LAKSHMI SAI VARA PRASAD THONTA
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Capgemini
SE
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689954000/f7151e69-7bd9-4702-be03-ebb6f0beb05f.jpg?itok=GWX3Wdig)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689954000/f7151e69-7bd9-4702-be03-ebb6f0beb05f.jpg?itok=GWX3Wdig)
CollabPartnerz
IN
Below link might help you
https://collaborate.pega.com/question/generate-and-download-pdf-document-browser-window
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689971000/18acbbb4-8ec5-4430-9b56-7689a26e7eed.jpg?itok=rhtbvErx)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689971000/18acbbb4-8ec5-4430-9b56-7689a26e7eed.jpg?itok=rhtbvErx)
Aaseya IT Services Pvt Ltd
GB
There is one more method.
Here, we can Print and Download the Section by making use of "PrintView" Harness.
Steps to follow:
1. Save as the OOTB "PrintView" harness from Work- to the current class.
2. Delete everything in the "PrintView" Harness and add a Container.
2. Add a section(You want to Print and Download) into the container present in "PrintView" harness.
3. Launch the "PrintView" harness on click of a button or link.
4. It will appear as the same in the following screenshot. There, you can print the form or else save as to PDF file.
-
Dinesh Bhargav Jorge Tena China Chiranjeevi Kothi Bhabani Shankar Jena