0

I'm using the following Java code in my pega(Java tool) activity to download the generated PDF document.

//Get the PDF bytes from parameter page.
ClipboardPage page = tools.findPage("eFormSource");
if(page == null){
  throw new PRRuntimeException("Source eForm doesn't exist");
}
Object pdfBytes = new Object();
pdfBytes=page.getObject("pyEForm");
if(pdfBytes == null){
  throw new PRRuntimeException("pdfBytes doesn't exist");
}
//Create the PDF name.
String listViewFileName="Consumer Tuberculosis.pdf";
byte[] byteArray=(byte[])pdfBytes;
//Send the PDF to the response.
String result=null;                                                                                       result=tools.sendFile(byteArray,listViewFileName,true,null,true);
//pdfBytes = new byte[pdfBytes.length];
//java.util.Arrays.fill(pdfBytes,0);
java.util.Arrays.fill(byteArray, (byte)0);

When a work object is opened and this code is invoked for the first time, the document gets downloaded.

When I try to invoke it the second time, the document doesn't download.

The object pyEform is created fresh upon every trial. If I close and reopen the work object and invoke this again for the first time, it works but later no matter how many times I invoke it, the document won't download.

What is wrong with my code?

Anything wrong with the use of the sendfile function or object instantiation?

jwpfox
  • 5,124
  • 11
  • 45
  • 42

0 Answers0