Beispiel #1
0
  /**
   * This will overlay a document and write out the results.<br>
   * <br>
   * usage: java PDF.Overlay &lt;overlay.pdf&gt; &lt;document.pdf&gt; &lt;result.pdf&gt;
   *
   * @param args The command line arguments.
   * @throws IOException If there is an error reading/writing the document.
   * @throws COSVisitorException If there is an error writing the document.
   */
  public static void main(String[] args) throws IOException, COSVisitorException {
    if (args.length != 3) {
      usage();
      System.exit(1);
    } else {
      PDDocument overlay = null;
      PDDocument pdf = null;

      try {
        overlay = getDocument(args[0]);
        pdf = getDocument(args[1]);
        Overlay overlayer = new Overlay();
        overlayer.overlay(overlay, pdf);
        writeDocument(pdf, args[2]);
      } finally {
        if (overlay != null) {
          overlay.close();
        }
        if (pdf != null) {
          pdf.close();
        }
      }
    }
  }