Extracted text = "D - 10-01"
May I know how to solve the problem when there have multiple text find collection in a PDF and I only need to draw a rectangle based on the position that I extracted by using Java. As currently now there have multiple same extracted keyword on the pdf and by using PdfTextFind[], it will draw a rectangle at the last position of the extracted text. How about if I want to draw a rectangle for the first or second occurrence and not for the last ? Hope you can help me solve my problems. Thanks.
Below here is my code....
- Code: Select all
result = pdfText.substring(lineWord + columnNo, lineWord + maxLength);
try {
PdfTextFindCollection pdfTextFineCollection = page.findText(result.trim());
PdfTextFind[] extractedResult = pdfTextFineCollection.getFinds();
for (PdfTextFind find : extractedResult) {
Point2D pointF = find.getPosition();
Dimension2D widthHeight = find.getSize();
double x = pointF.getX();
double y = pointF.getY();
double width = widthHeight.getWidth();
double height = widthHeight.getHeight();
position.setX(x);
position.setY(y);
position.setHeight(height);
position.setWidth(width);
}
} catch (Exception e) {
}