Hi Aspose,
I’d like to create a pdf like in “pdf-sample_highlighted_by_adobe.pdf”, can you let me know how to do it using setQuadPoints() API? My code below produced “pdf-sample_highlighted_by_aspose.pdf”.
String inputFilePath = “D:\tmp\Tuyen\testPdf\pdf-sample.pdf”;
String outputFilePath = “D:\tmp\Tuyen\testPdf\pdf-sample_highlighted_by_aspose.pdf”;
try (InputStream inStream = new FileInputStream(inputFilePath);
OutputStream outStream = new FileOutputStream(outputFilePath)) {
Document pdfDocument = new Document(inStream);
Page page = pdfDocument.getPages().get_Item(1);
double llx = 85.7114;
double lly = 656.144;
double urx = 509.957;
double ury = 686.697;
Rectangle rect = new Rectangle(llx, lly, urx, ury);
HighlightAnnotation annotation = new HighlightAnnotation(page, rect);
Color color = Color.YELLOW;
annotation.setColor( com.aspose.pdf.Color.fromRgb(color));
annotation.setTitle(“vntun”);
annotation.setSubject(“vntun sub”);
Point[] points = new Point[]{getPoint(201.458, 686.204),
getPoint(505.748, 686.204),
getPoint(201.458, 670.436),
getPoint(505.748, 670.436),
getPoint(89.9206, 672.404),
getPoint(250.49, 672.404),
getPoint(89.9206, 656.636),
getPoint(250.49, 656.636)
};
annotation.setQuadPoints(points);
page.getAnnotations().add(annotation);
pdfDocument.save(outStream);
}
public static Point getPoint(double x, double y) {
return new Point(x, y);
}
Please note that the points data above is from getQuadPoints when I tried to read HighlightAnnotation from “pdf-sample_highlighted_by_adobe.pdf”. I’m using Aspose pdf 17.2.0.
Thank you.
Best Regards,
Tuyen