title: How to delete attachment of PDF using itext
body: <p>I am new to pdf and i use the following code to embed the file to pdf. However, I want to write another program to delete the embeded files. May I know how can I do it? Really Thanks!</p>
  
  <pre><code>public void addAttachments(String src, String dest, String[] attachments) throws IOException,DocumentException {
  PdfReader reader = new PdfReader(src);
  PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
  for (int i = 0; i &lt; attachments.length; i++) {
          addAttachment(stamper.getWriter(), new File(attachments[i]));
                                    }
                                    stamper.close();
                                  }
  
                                  protected void addAttachment(PdfWriter writer, File src) throws IOException {
                                    PdfFileSpecification fs =
                                      PdfFileSpecification.fileEmbedded(writer, src.getAbsolutePath(), src.getName(), null);
                                    writer.addFileAttachment(src.getName().substring(0, src.getName().indexOf('.')), fs);
                                  }
  </code></pre>