Fix#20 OCR pdf text not selectable
This commit is contained in:
@@ -144,7 +144,7 @@ async function runOCR() {
|
|||||||
binarizeCanvas(context);
|
binarizeCanvas(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await worker.recognize(canvas);
|
const result = await worker.recognize(canvas, {}, { text: true, hocr: true });
|
||||||
const data = result.data;
|
const data = result.data;
|
||||||
const newPage = newPdfDoc.addPage([viewport.width, viewport.height]);
|
const newPage = newPdfDoc.addPage([viewport.width, viewport.height]);
|
||||||
const pngImageBytes = await new Promise((resolve) =>
|
const pngImageBytes = await new Promise((resolve) =>
|
||||||
@@ -192,7 +192,7 @@ async function runOCR() {
|
|||||||
font,
|
font,
|
||||||
size: fontSize,
|
size: fontSize,
|
||||||
color: rgb(0, 0, 0),
|
color: rgb(0, 0, 0),
|
||||||
opacity: 0,
|
opacity: 0.1,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If drawing fails despite sanitization, log and skip this word
|
// If drawing fails despite sanitization, log and skip this word
|
||||||
|
|||||||
Reference in New Issue
Block a user