3

I have a PDDocument object on a WAS and it needs to be transmitted to a client server to be used there.
The pddocument is not serializable so I have to find another solution to get it there.

I am now thinking of doing this:
1. On the WAS: saving the PDDocument to a ByteArrayOutputStream and passing that outputstream to the client server. Like this:

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
document.save(byteArrayOutputStream);
document.close();

2. And on the client server: reading in the passed outputstream with the load() method of PDDocument.
So:

InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());

Is this a good solution or are their better ways to do this?

  • 1
    *"Is this a good solution"* - yes, it is. At least there is no universally better one. You don't mention, though, why you explicitly want to transfer a `PDDocument` object instead of simply a pdf file, so I don't know whether doing this will cause you any trouble. – mkl Dec 17 '18 at 05:44

0 Answers0