title: How to extract the byte [] array from a PdfDocument
body: <p>After a lot of researching, I still can't find a way to extract a <code>byte[]</code> from a PdfDocument object. How can I achieve this?</p>
  
  <p>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 <code>byte[]</code>. </p>
  
  <p>Can someone give me a hand with this? </p>
  
  <pre><code>    PdfDocument pdfDocumentWithoutSplit = getPdfUtils().generatePdfDocumentByMedia(shippingLabel);
  
          for (int i = 1; i &lt; 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
  
          }
  </code></pre>
  
  <p>Cheers</p>