Converting an output stream to an input stream

Hello,I would like to know if there is any problems in chaining output streams to input streams

of aspose manipulated edited pdf documents in pdf kit for java.

Say I wish to save a resultant pdf file of a form save operation and then convert this output

stream to an input steam and use this as a source document in new operation like

1. save (inputstream1, finalOutputStream)

inputstream2 = finalOutputStream

2. inputstream2 = finalOutputStream

can just keep a saved outputstream and load it into an inputstream and save the result in a

final output stream ?

Is there some special conversion to an input stream in a manner,how dependable is using a filedescriptor as a output location,and can I modify this document many times?

Thanking You

Andrew

Hi Andrew,

Thank you for considering Aspose.

We'll look into the details of your requirement and will update you with the results the earliest possible.

Regards,

Hi Andrew,

I just wanted to update you that you can't use java.io.OutputStream directly where java.io.InputStream is required. However, if you can convert an output stream into input stream then you can use them, and chain them, whereever Aspose components explicity specify the InputStream and OutputStream. You can take an output stream from one class, convert it into input stream and pass it to the component where input stream is acceptable.

You might get some help from the below link:

http://ostermiller.org/convert_java_outputstream_inputstream.html

If you find any issues or some more questions, please do let us know.

Regards,

Dear Andrew,

The answer for your question is YES. You can accomplish it with the following steps:

1. Create a middle stream like this:
ByteArrayOutputStream outStrm= new ByteArrayOutputStream();
BufferedOutputStream midStream = new BufferedOutputStream(outStrm);
Form formA = new Form(InputFileName, midStream);
... other codes ...

2. Obtain contents byte array from the middle stream like this:
byte[] buffer = outStrm.toByteArray();

3. Create an InputStream from the contents array like this:
ByteArrayInputStream bufferIn = new ByteArrayInputStream(buffer);
Form formB = new Form(inStrm, OutputFileName);
... other codes ...

Hope it works & Best regards.

I am afraid that when I tested for my above reply, Shahzad already gave a quick reply. Basicly, my solution is the first way which has been pointed out by the web link. Any way, hope it helps. If you still have any other question, please feel free to tell us :)