I am having this exact problem, but only when I call my orchestration remotely by SOAP. When I make the call on the same server where LiveCycle resides it's fine. Anyone?? I'm using LC 8.2.
I have the answer. You mustn't rely on InputStream.available() nor should you rely on InputStream.read(byte b) getting all the data all the time. It only gets the data that are "available" at that time. More data may become available after the read. It's asynchronous on some level. Better is to read from the InputStream in a loop until you find the end of the file, which is determined by InputStream.read(byte b) returning -1. This works for me:
ServletOutputStream oOutput = response.getOutputStream();
InputStream oDocInputStream = oDocument.getInputStream();
byte buffer = new byte[(int)oDocument.length()];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((bytesRead = oDocInputStreamread(buffer)) != -1)
baos.write(buffer, 0, bytesRead);
Hope this helps someone avoid the time loss that I experienced on this one.
Thank you for that solution, it saved me the time to figure it out by myself.