Question

3
Replies
126
Views
pradeepp4826 Member since 2016 4 posts
CSC
Posted: 1 year ago
Last activity: 1 year 10 months ago
Closed

how to Pass image file to eform

Hi All,

I have a business requirement to embed user photograph in pdf generated by e-forms.

property of type image is defined in pdf template and corresponding e-form map rule is mapped with clipboard property of type text. is this right configuration to make it work?

tried with following options with no luck.

1. using java io api (photo is the text property used in map rule)

String strFilePath=tools.getParamValue("FilePath");

java.io.File file = new java.io.File(strFilePath);

byte[] bytesArray = new byte[(int) file.length()];

java.io.FileInputStream fis = new java.io.FileInputStream(file);

fis.read(bytesArray); //read file into bytes[]
fis.close();

tools.putParamValue("FileBytes",bytesArray);

myStepPage.putString("Photo",tools.getParamValue("FileBytes"));

2. This is being failed as trying to assign output stream object to photo (text) property.

String strFilePath=tools.getParamValue("FilePath");
java.io.File file = new java.io.File(strFilePath);
byte[] bytesArray = new byte[(int) file.length()];
java.io.FileInputStream fis = new java.io.FileInputStream(file);
//fis.read(bytesArray); //read file into bytes[]
//fis.close();
// tools.putParamValue("FileBytes",bytesArray);
// myStepPage.putString("Photo",tools.getParamValue("FileBytes"));
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream((int)file.length());
byte buffer[] = new byte[1024];
int bytesRead = 0;
while ((bytesRead = fis.read(buffer))!=-1) {
baos.write(buffer, 0, bytesRead);
}
fis.close();
baos.flush();
baos.close();
ClipboardProperty eformProp = myStepPage.getProperty("Photo");
eformProp.setValue(baos.toByteArray());
any suggestion how to overcome this? what are the other parameters to be considered while implementing it?
Thanks in advance for the help.
Regards
Pradeep

***Updated by moderator: Lochan to update platform capability***

Data Integration User Interface
Moderation Team has archived post
Share this page LinkedIn