Question
OCBC
SG
Last activity: 2 Aug 2018 3:21 EDT
How to preview any attachment(docx, jpg, pdf, xlsx) that have been attached to a work object?
How can we preview any attachment (it can be of any format) that has been attached to a work object? I tried with creating a control but I'm able to preview files only with image extensions (jpg and png). It is not working for other document types.
Can anyone suggest a solution for this?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Ncs Pte Ltd
SG
Try this activity Work-.DisplayAttachFile
OCBC
SG
Hi Rohit,
This activity sends the file for download. I need to preview the file. The user shouldn't be able to download the file.
Any other option?
Thanks
Pegasystems Inc.
IN
Hi There,
This feature is not available OOTB in Pega.
To make this happen you have to take help of 3rd party APIs and a lot of efforts.
Thanks,
Ujjwal
-
Neal Fischer
OCBC
SG
Thanks for the update Ujjwal!
Regards,
Sovan
Merkle
ES
Hi All,
For what it's worth i'm working on a solution to this that doesn't require Pega 7.4
You can use the following code in a custom control
<%
String srcURL = StringUtils.crossScriptingFilter(tools.getParamValue("pdfURL"));
String fileName = StringUtils.crossScriptingFilter(tools.getParamValue("fileName"));if ("".equals(srcURL) || "".equals(fileName)){
srcURL = "./webwb/blankimage.png";
}else{
srcURL += '/';
srcURL += fileName;
}String sWidth = StringUtils.crossScriptingFilter(tools.getParamValue("width"));
if ("".equals(sWidth)) {
sWidth = "160";
}String sHeight = StringUtils.crossScriptingFilter(tools.getParamValue("height"));
if ("".equals(sHeight)) {
sHeight = "120";
}
%><iframe width="<%=sWidth%>" height="<%=sHeight%>" src="<%=srcURL%>" allowfullscreen="false"></iframe>
The custom control needs to take params of
pdfURL
fileName
width
height
width and height can be whatever you want
pdf url you can get from the pxThread page, property pxThread.pxReqExportURI
fileName you need to get from the attachment pages, in .pyFileName
Hi All,
For what it's worth i'm working on a solution to this that doesn't require Pega 7.4
You can use the following code in a custom control
<%
String srcURL = StringUtils.crossScriptingFilter(tools.getParamValue("pdfURL"));
String fileName = StringUtils.crossScriptingFilter(tools.getParamValue("fileName"));if ("".equals(srcURL) || "".equals(fileName)){
srcURL = "./webwb/blankimage.png";
}else{
srcURL += '/';
srcURL += fileName;
}String sWidth = StringUtils.crossScriptingFilter(tools.getParamValue("width"));
if ("".equals(sWidth)) {
sWidth = "160";
}String sHeight = StringUtils.crossScriptingFilter(tools.getParamValue("height"));
if ("".equals(sHeight)) {
sHeight = "120";
}
%><iframe width="<%=sWidth%>" height="<%=sHeight%>" src="<%=srcURL%>" allowfullscreen="false"></iframe>
The custom control needs to take params of
pdfURL
fileName
width
height
width and height can be whatever you want
pdf url you can get from the pxThread page, property pxThread.pxReqExportURI
fileName you need to get from the attachment pages, in .pyFileName
Problem is, this will only work on a one node solution.
Whenever the file is uploaded on one node, and viewed on another, it won't work. I guess this is because the ServiceExport folder is only populated on the node you upload to, which we reference in the pxThread.pxReqExportURI property.
if anyone knows a solution to this, please let us know.
Thanks,
OCBC
SG
Thanks Anna! Shall give it a go.