이미지 작업

현재 Java PdfContentEditorExamples 클래스는 replaceImage(...)을 직접 지원합니다.

이미지 교체

  1. 소스 PDF를 PdfContentEditor 파사드에 바인딩하세요.
  2. 페이지 번호, 이미지 인덱스, 대체 이미지 경로를 전달하여 replaceImage(...)를 호출하세요.
  3. 업데이트된 PDF 문서를 저장하세요.
public static void replaceImage(Path inputFile, Path imageFile, Path outputFile) {
    PdfContentEditor editor = new PdfContentEditor();
    try {
        editor.bindPdf(inputFile.toString());
        editor.replaceImage(1, 1, imageFile.toString());
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}