What is the best way to rebuild a PDDocument(from PDFBox)?

Viewed 91

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?

0 Answers
Related