title: Remove duplicated fonts in a PDF using iText
body: <p>i'm using iText 2.1.5 to merge 2 PDF files. My problem is, when the concatenated pdf is generated, all fonts used in both pdf are duplicated. Is there a better way to handle this, so that the fonts only get embedded once ?</p>
  
  <p>source code : </p>
  
  <pre><code>    public class GroupingPDF {
  
      public static final String RESULT = "/home/asagaama/Documents/groupementpdf/get/concatenated.pdf";;
  
      public static void main(String[] args) {
          try {
              String[] files = {
                      "/home/asagaama/Documents/groupementpdf/get/1.pdf",
                      "/home/asagaama/Documents/groupementpdf/get/2.pdf" };
              Document document = new Document();
              PdfSmartCopy pdfSmartCopy = new PdfSmartCopy(document,
                      new FileOutputStream(RESULT));
              document.open();
              PdfReader reader;
  
              int n;
              // loop over the documents you want to concatenate
              for (int i = 0; i &lt; files.length; i++) {
                  reader = new PdfReader(files[i]);
                  // loop over the pages in that document
                  n = reader.getNumberOfPages();
                  for (int page = 0; page &lt; n;) {
                      pdfSmartCopy.addPage(pdfSmartCopy.getImportedPage(reader,
                              ++page));
                  }
              }
              document.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>