Java를 사용하여 PDF 파일에서 이미지 삭제
Contents
[
Hide
]
PDF 페이지에 포함된 이미지를 제거해야 하는 경우 페이지 이미지 리소스 컬렉션을 사용하세요.
인덱스별로 포함된 이미지 삭제
- 원본 PDF
Document를 여세요. - 대상
Page의 이미지 리소스에 접근하세요. - 해당 인덱스를 기준으로 페이지 리소스 컬렉션에서 대상 이미지를 삭제하세요.
- 업데이트된 PDF
Document를 저장하세요.
public static void deleteImage(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
document.getPages().get_Item(1).getResources().getImages().delete(1);
document.save(outputFile.toString());
}
}