Java를 통한 모양 주석
Contents
[
Hide
]
모양 주석 추가
- 입력 PDF를 열고 모양 주석을 포함할 페이지와 직사각형을 선택하세요.
- 필요한 모양 주석을 생성한 다음 필요할 때 제목, 색상, 불투명도 및 점을 설정하세요.
- 페이지에 주석을 추가하고 수정된 PDF를 저장하세요.
public static void squareAnnotationAdd(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
SquareAnnotation squareAnnotation = new SquareAnnotation(
document.getPages().get_Item(1), new Rectangle(60, 600, 250, 450, true));
squareAnnotation.setTitle("John Smith");
squareAnnotation.setColor(Color.getBlue());
squareAnnotation.setInteriorColor(Color.getBlueViolet());
squareAnnotation.setOpacity(0.25);
document.getPages().get_Item(1).getAnnotations().add(squareAnnotation);
document.save(outputFile.toString());
}
}
public static void polygonAnnotationAdd(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
PolygonAnnotation polygonAnnotation = new PolygonAnnotation(
document.getPages().get_Item(1),
new Rectangle(200, 300, 400, 400, true),
new Point[]{
new Point(200, 300),
new Point(220, 300),
new Point(250, 330),
new Point(300, 304),
new Point(300, 400)
});
polygonAnnotation.setTitle("John Smith");
polygonAnnotation.setColor(Color.getBlue());
polygonAnnotation.setInteriorColor(Color.getBlueViolet());
polygonAnnotation.setOpacity(0.25);
document.getPages().get_Item(1).getAnnotations().add(polygonAnnotation);
document.save(outputFile.toString());
}
}