Skip to content

Commit c568b10

Browse files
author
Joris Schellekens
committed
fix broken test by correcting off-by-one error in RegexBasedLocationExtractionStrategy
DEVSIX-1816
1 parent ad10dfe commit c568b10

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Collection<IPdfTextLocation> getResultantLocations() {
8888
while (mat.find()) {
8989
int startIndex = txt.indexMap.get(mat.start());
9090
int endIndex = txt.indexMap.get(mat.end() - 1);
91-
for (Rectangle r : toRectangles(parseResult.subList(startIndex, endIndex))) {
91+
for (Rectangle r : toRectangles(parseResult.subList(startIndex, endIndex + 1))) {
9292
retval.add(new DefaultPdfTextLocation(0, r, mat.group(0)));
9393
}
9494
}

kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void test01() throws IOException {
8989
Assert.assertEquals(loc.getText(), "{{Signature}}");
9090
Assert.assertEquals(23, (int) loc.getRectangle().getX());
9191
Assert.assertEquals(375, (int) loc.getRectangle().getY());
92-
Assert.assertEquals(52, (int) loc.getRectangle().getWidth());
92+
Assert.assertEquals(55, (int) loc.getRectangle().getWidth());
9393
Assert.assertEquals(11, (int) loc.getRectangle().getHeight());
9494

9595
// close

0 commit comments

Comments
 (0)