title: How to convert a PDFBox PDPageContentStream to a byteArrayInputStream
body: <p>I am trying to understand how to use PDFBox in a web application.
  PDFBox examples everywhere says to use the file system to save the file first.
  Here is an example from web....
  try (PDDocument doc = new PDDocument()) {</p>
  <pre><code>        PDPage myPage = new PDPage();
          doc.addPage(myPage);
  
          try (PDPageContentStream cont = new PDPageContentStream(doc, myPage)) {
  
              cont.beginText();
              .....
              cont.endText();
          }
  
          doc.save(&quot;src/main/resources/wwii.pdf&quot;);
  </code></pre>
  <p>}</p>
  <p>But how can I do that in a webapplication (deployed in WebLogic) in a production environment????
  Because after the application is deployed, I cannot say to write to a file system because we do not know what type of a file system it is used.
  The only way out is to know how to convert the cont object to a byte array and store it in the memory before displaying..</p>
  <p>I tried significant amount of time to find out how to coinvert the cont object in the above example to a byte array input stream to I could use it in the next step - which is displaying it in a webpage.</p>