public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(ReplaceImage.class);
    // open input PDF
    PdfContentEditor pdfContentEditor = new PdfContentEditor();
    pdfContentEditor.bindPdf(dataDir + "Input.pdf");

    // replace image on a particular page
    pdfContentEditor.replaceImage(1, 1, dataDir + "image2.bmp");

    // save output PDF
    pdfContentEditor.save(dataDir + "Output.pdf");
  }