Skip to content

Commit 1b103fe

Browse files
committed
Use positive dimensions for text chunks in the text layer (issue #14415).
1 parent 2ca432d commit 1b103fe

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/core/evaluator.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,8 @@ class PartialEvaluator {
23672367
return {
23682368
str,
23692369
dir: bidiResult.dir,
2370-
width: textChunk.totalWidth,
2371-
height: textChunk.totalHeight,
2370+
width: Math.abs(textChunk.totalWidth),
2371+
height: Math.abs(textChunk.totalHeight),
23722372
transform: textChunk.transform,
23732373
fontName: textChunk.fontName,
23742374
hasEOL: textChunk.hasEOL,
@@ -2484,7 +2484,7 @@ class PartialEvaluator {
24842484
str: " ",
24852485
dir: "ltr",
24862486
width: 0,
2487-
height: advanceY,
2487+
height: Math.abs(advanceY),
24882488
transform: textContentItem.prevTransform,
24892489
fontName: textContentItem.fontName,
24902490
hasEOL: false,
@@ -2523,7 +2523,7 @@ class PartialEvaluator {
25232523
textContent.items.push({
25242524
str: " ",
25252525
dir: "ltr",
2526-
width: advanceX,
2526+
width: Math.abs(advanceX),
25272527
height: 0,
25282528
transform: textContentItem.prevTransform,
25292529
fontName: textContentItem.fontName,
@@ -2677,8 +2677,8 @@ class PartialEvaluator {
26772677
// TODO: check if using the orientation from last chunk is
26782678
// better or not.
26792679
dir: "ltr",
2680-
width,
2681-
height,
2680+
width: Math.abs(width),
2681+
height: Math.abs(height),
26822682
transform: transf || getCurrentTextTransform(),
26832683
fontName,
26842684
hasEOL: false,

test/pdfs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -500,3 +500,4 @@
500500
!poppler-937-0-fuzzed.pdf
501501
!PDFBOX-3148-2-fuzzed.pdf
502502
!poppler-90-0-fuzzed.pdf
503+
!issue14415.pdf

test/pdfs/issue14415.pdf

52.6 KB
Binary file not shown.

test/test_manifest.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -6191,5 +6191,11 @@
61916191
"link": true,
61926192
"rounds": 1,
61936193
"type": "eq"
6194-
}
6194+
},
6195+
{ "id": "issue14415",
6196+
"file": "pdfs/issue14415.pdf",
6197+
"md5": "fa306a250a3d37fe0e7a4b3bba51c91e",
6198+
"link": true,
6199+
"type": "text"
6200+
}
61956201
]

0 commit comments

Comments
 (0)