Question
Accenture
IT
Last activity: 18 Sep 2018 5:51 EDT
How to show a PDF stream after generating it (no case to attach)?
Hi all,
I need your help to face this issue.
As a requirement, I need to generate and open a PDF (with some prepopulated data) directly from the dashboard.
So i have no cases that i can use to attach the PDF and then open the attachment directly from the case.
I am able to create the stream and save it into a Page, but I am not able to show that stream to the user.
Has anyone faced the same requirement? Can you please help me?
Thank you very much.
***Edited by Moderator Marissa to update categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Accenture
IT
Hi all,
thank you for your help.
The final solution is the one that follows:
1) Define in Pages&Classes an "eFormPage" of class Code-Pega-eForm
2) Call from the eFormPage the GenerateEForm activity
3) Call from the same step page the ConcateateEForms activity
4)Set parameters
- PDFDocument equals to eFormPage.pyEForm
- PDFName equals to "Test.pdf"
5) now i have implemented a java step, copying code from View activity of class Code-Pega-PDF. Doing so I am able to modify the last flag for sendFile, from true to false, to enable display of generated PDF and not its automatic download.
Here you find the referenced and modified code
//Get the byte array from the parameter page
byte[] byteArray=(byte[])tools.getParameterPage().getParameterValue("PDFDocument");//Get the pdf name from the parameter page
String pdfName=tools.getParamValue("PDFName");//Send the PDF File back to the user.
String result=tools.sendFile(byteArray,pdfName,false,null,false);
If you want to directly download the generated PDF, you can simply call the View Activity using a Code-Pega-PDF step page.
Regards,
Vince
Pegasystems Inc.
IN
Hi Vince,
You may try Connect-File in an Activity with "Write From eForm" method.
Running the activity would generate PDF at mentioned directory in Connect-File rule.
Thanks,
Ujjwal
Accenture
IT
Hi,
I have tried to but with no success as the path specified in the connector rule points to the directory of the server, while I should let the single operator save the pdf instance directly on his laptop or desktop, as it has no access to server directories.
By the way, thank you!
Vince
Virtusa IT Consulting
AE
You can pass the Binary stream data to 'HTMLToPDF' activity and generate PDF.
Accepted Solution
Accenture
IT
Hi all,
thank you for your help.
The final solution is the one that follows:
1) Define in Pages&Classes an "eFormPage" of class Code-Pega-eForm
2) Call from the eFormPage the GenerateEForm activity
3) Call from the same step page the ConcateateEForms activity
4)Set parameters
- PDFDocument equals to eFormPage.pyEForm
- PDFName equals to "Test.pdf"
5) now i have implemented a java step, copying code from View activity of class Code-Pega-PDF. Doing so I am able to modify the last flag for sendFile, from true to false, to enable display of generated PDF and not its automatic download.
Here you find the referenced and modified code
//Get the byte array from the parameter page
byte[] byteArray=(byte[])tools.getParameterPage().getParameterValue("PDFDocument");//Get the pdf name from the parameter page
String pdfName=tools.getParamValue("PDFName");//Send the PDF File back to the user.
String result=tools.sendFile(byteArray,pdfName,false,null,false);
If you want to directly download the generated PDF, you can simply call the View Activity using a Code-Pega-PDF step page.
Regards,
Vince
Infosys Ltd
IN
Hi, I am able to download the file but my requirement is to download the file with out asking any option 'Open' or 'Save' file should auto download.
Below code is working for auto download but when user try to save the same, file name showing some thread name(having issue only in IE).
com.pega.pegarules.pub.util.Base64Util base = new com.pega.pegarules.pub.util.Base64Util();
String LTRFileName = tools.getParamValue("FileName");
String EDGSContent = tools.getParamValue("EDGSBinaryContent");
LTRFileName = LTRFileName+".pdf";
HashStringMap aMap = new HashStringMap();
aMap.put( "ContentDisposition", "inline; filename="+LTRFileName+";");
byte[] printData = base.decode(EDGSContent.getBytes());
String sErrorMessage1 = tools.sendFile(printData, LTRFileName, false,aMap, false);
Please suggest me to acheive my requirement.
Thanks,
Gopal
Pegasystems Inc.
IN
Hi Gopal,
In increase the visibility for your question, we've created a new post for you: Need to auto download the file without the options Open and Save file
Please continue the discussion on the new post.
Regards,