Question
Phalanx Consultancy Services
GB
Last activity: 20 Oct 2021 8:45 EDT
How to View a PDF file inline uploaded in the rule-file-binary
Hi Everyone,
I have come across a requirement to view a pdf file in-line on the screen , which is uploaded in the rule-file-binary. I saw a similar implementation where any pdf attachments in the case, can be previewed.
I tried using a similar logic which is used in the activity "DisplayAttachFile" and "pyAttachmentPreview" section embedded in the "pyCaseMainAddInfo" in the class "PegaSocial-Document". but all i see is a icon of the file and not the file..
Below are the steps i followed:
1. Created an embedded section "pxFilePreview" in which an new activity "Test" is passed as a parameter and this activity in turn has parameters like the file name, type and the directory.
2. Created "test" activity which takes the parameters of file name, directory and type and does an obj-browse of the Rule-FIle-Binary and gets the inskey and other parameters.
3. now once the key is retrieved, passing it to a java step which does a send file
DocPage - obj-browse step page
snippet of the code used:
DocPage = tools.findPage("DocPage");
Hi Everyone,
I have come across a requirement to view a pdf file in-line on the screen , which is uploaded in the rule-file-binary. I saw a similar implementation where any pdf attachments in the case, can be previewed.
I tried using a similar logic which is used in the activity "DisplayAttachFile" and "pyAttachmentPreview" section embedded in the "pyCaseMainAddInfo" in the class "PegaSocial-Document". but all i see is a icon of the file and not the file..
Below are the steps i followed:
1. Created an embedded section "pxFilePreview" in which an new activity "Test" is passed as a parameter and this activity in turn has parameters like the file name, type and the directory.
2. Created "test" activity which takes the parameters of file name, directory and type and does an obj-browse of the Rule-FIle-Binary and gets the inskey and other parameters.
3. now once the key is retrieved, passing it to a java step which does a send file
DocPage - obj-browse step page
snippet of the code used:
DocPage = tools.findPage("DocPage");
String userAgentString = pega_rulesengine_utilities.pzGetUserAgentString(tools); if((userAgentString.indexOf("Chrome/") > 0 || userAgentString.indexOf("Edge/")> 0) || userAgentString.indexOf("Firefox/") > 0 || userAgentString.indexOf("Safari/") > 0){ headers = new HashStringMap(); headers.put("ContentType", "application/pdf"); headers.put("ContentDisposition", "inline;filename=\""+org.apache.commons.lang.StringEscapeUtils.unescapeHtml(tools.getParamValue("FileName"))+".pdf\";filename*=UTF-8''"+StringUtils.encodeURL(tools.getParamValue("FileName"))+".pdf"); }
sErrorMessage = tools.sendFile(DocPage, "pyFileSource", true, "pyFileName" + ".pdf", null, false, headers, download); tools.getThread().getThreadPage().putString("pyXMLStream", sErrorMessage); pega.terminateActivity();
Appreciate any help on the similar implementations