Skip to content

Commit c302bc9

Browse files
committed
Prevent 0px left/top OCR words from rendering on the page
1 parent 62615a8 commit c302bc9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/plugins/plugin.text_selection.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ export class TextSelectionPlugin extends BookReaderPlugin {
137137
if ($textLayers.length) return;
138138
const XMLpage = await this.getPageText(pageIndex);
139139
if (!XMLpage) return;
140+
// Seeing some 0 left and 0 top coordinates in ToC, remove it entirely to prevent odd rendering
141+
$(XMLpage).find("WORD").filter((_, ele) => {
142+
const [left, bottom, right, top] = ele.getAttribute('coords').split(",").map(parseFloat);
143+
if (left != 0 || top != 0) {
144+
return false;
145+
}
146+
return true;
147+
}).remove();
140148
recursivelyAddCoords(XMLpage);
141149

142150
const totalWords = $(XMLpage).find("WORD").length;

0 commit comments

Comments
 (0)