Fix#20 OCR pdf text not selectable

This commit is contained in:
Shirshendu R Tripathi
2025-10-19 22:12:51 +05:30
parent caf23b0ab9
commit ef7b9d0365

View File

@@ -144,7 +144,7 @@ async function runOCR() {
binarizeCanvas(context);
}
const result = await worker.recognize(canvas);
const result = await worker.recognize(canvas, {}, { text: true, hocr: true });
const data = result.data;
const newPage = newPdfDoc.addPage([viewport.width, viewport.height]);
const pngImageBytes = await new Promise((resolve) =>
@@ -192,7 +192,7 @@ async function runOCR() {
font,
size: fontSize,
color: rgb(0, 0, 0),
opacity: 0,
opacity: 0.1,
});
} catch (error) {
// If drawing fails despite sanitization, log and skip this word