After a lot of researching, I still can't find a way to extract a byte[]
from a PdfDocument object. How can I achieve this?
I've tried with FileInputStream, but actually I don't have the "physical path" of the PdfDocument because I'm creating one programmatically. Moreover, I'm not very familiar with the byte[]
.
Can someone give me a hand with this?
PdfDocument pdfDocumentWithoutSplit = getPdfUtils().generatePdfDocumentByMedia(shippingLabel);
for (int i = 1; i < pdfDocumentWithoutSplit.getNumberOfPages() + 1; i++) {
final ByteArrayOutputStream pdfByteArray = new ByteArrayOutputStream();
final PdfDocument pdfDocument = new PdfDocument(new PdfWriter(pdfByteArray));
pdfDocument.movePage(pdfDocumentWithoutSplit.getPage(i), i);
pdfByteArray.close();
//now here I need to get the bytes of each pdfDocument somehow
}
Cheers