I am using itext in Java for updating a pdf file.
- I read the pdf
- I update the content (get PRStream, convert into stream then string, update the string, convert it back PRStream)
I regenerate the output file using
pdfStamper = new PdfStamper(pdfReader, new FileOutputStream("new-file.pdf"));
It's working all fine, now I want to send the stream as output to a rest API call, how can I convert pdfReader
to byte[]
I have been able to save the file and then read the stream from it using
byte[] stream = Files.readAllBytes(file.toPath());
but I don' want to save the file, I want to retrieve the stream directly instead of saving the file and then getting byte[]
of the newly generated pdf