title: How to extract attached files from PDF with itext7
body: <p>How does one extract attached files from a PDF with itext7?</p>
  
  <p>The sample codes I found for itext5 all don't work any more.</p>
  
  <p>A <code>byte[]</code> per file would be what I need, as in the itext5 example below:</p>
  
  <pre><code>    PdfReader reader = new PdfReader(SRC);
      Map&lt;String, byte[]&gt; files = new HashMap&lt;String,byte[]&gt;();
      PdfObject obj;
  
      for (int i = 1; i &lt;= reader.getXrefSize(); i++) {
          obj = reader.getPdfObject(i);
          if (obj != null &amp;&amp; obj.isStream()) {
              PRStream stream = (PRStream)obj;
              byte[] b;
              try {
                  b = PdfReader.getStreamBytes(stream);
              }
              catch(UnsupportedPdfException e) {
                  b = PdfReader.getStreamBytesRaw(stream);
              }
              files.put(Integer.toString(i), b);
          }
      }
  </code></pre>
  
  <p>Thx /markus</p>