Troubleshooting
문서가 닫히지 않음 — 메모리 누수
Document는 AutoCloseable을(를) 구현합니다. 항상 try-with-resources 블록을 사용하십시오:
try (Document doc = new Document("input.pdf")) {
// operations
} // doc.close() called automaticallyOutOfMemoryError와 대용량 파일
대용량 문서의 경우, PdfFileEditor에서 디스크 버퍼링을 활성화하십시오:
PdfFileEditor editor = new PdfFileEditor();
editor.setUseDiskBuffer(true);
editor.concatenate(inputFiles, "output.pdf");PdfFileSecurity: 잘못된 비밀번호
decryptFile(password)는 제공된 비밀번호가 올바르지 않을 경우 false을 반환합니다. 항상 반환값을 확인하고 실패 경우를 처리하십시오:
try (PdfFileSecurity security = new PdfFileSecurity()) {
security.setInputFile("encrypted.pdf");
security.setOutputFile("decrypted.pdf");
boolean ok = security.decryptFile("ownerPassword");
if (!ok) {
System.err.println("Decryption failed — verify the owner password.");
}
}PdfFileEditor: null 인수
PdfFileEditor.resizeContents()은 예외를 발생시키는 대신 null 인수를 조용히 무시합니다. resizeContents() 후에 출력 문서가 변경되지 않은 것처럼 보이면, ContentsResizeParameters 인수가 null이 아닌지와 백분율 값이 정확히 100이 되는지 확인하십시오.
AESCipher: 잘못된 키 길이
AES는 정확히 16, 24, 또는 32바이트(128, 192, 또는 256비트)의 키가 필요합니다. 길이가 올바르지 않은 키를 전달하면 기본 Java 암호 제공자에서 예외가 발생합니다.
주석이 표시되지 않음
주석을 추가했지만 뷰어에 표시되지 않는 경우, 다음을 확인하십시오:
- 주석 사각형이 페이지의
MediaBox내에 있는지 확인하십시오 page.getAnnotations().add(annotation)이(가) 모든 속성을 구성한 후에 호출되었습니다- 주석을 추가한 후 문서가 저장되었습니다