Product: PDFTron
Product Version: 9.2.0-1
Please give a brief summary of your issue: PDFTron SDK not able to find OCR module
Please describe your issue and provide steps to reproduce it:
So I am using PDFTron SDK in my Node.js app in a linux environment (Pop OS 22.04). I am facing a problem that the SDK is not able to find the OCR module.
I even downloaded the module and extracted the zip file, put it in a lib folder and passed the path of that folder to this function PDFNet.addResourceSearchPath('path to my lib folder')
but that didn’t work. So I passed the path of the OCR module folder itself placed in my lib folder but again got the same error.
Error I got:
Unable to run OCRTest: PDFTron SDK OCR module not available.
The OCR module is an optional add-on, available for download
at http://www.pdftron.com/. If you have already downloaded this
module, ensure that the SDK is able to find the required files
using the PDFNet.addResourceSearchPath() function.
Here is the code where I used PDFNet.addResourceSearchPath()
:
async function _extract(file) {
try {
await PDFNet.addResourceSearchPath('../../lib');
const useIRIS = await PDFNet.OCRModule.isIRISModuleAvailable();
if (!(await PDFNet.OCRModule.isModuleAvailable())) {
console.log('\nUnable to run OCRTest: PDFTron SDK OCR module not available.');
console.log('---------------------------------------------------------------');
console.log('The OCR module is an optional add-on, available for download');
console.log('at http://www.pdftron.com/. If you have already downloaded this');
console.log('module, ensure that the SDK is able to find the required files');
console.log('using the PDFNet.addResourceSearchPath() function.\n');
throw new ServiceError();
}
const doc = await PDFNet.PDFDoc.createFromBuffer(file.buffer);
await doc.initSecurityHandler();
const opts = new PDFNet.OCRModule.OCROptions();
setLanguage(useIRIS, opts);
await PDFNet.OCRModule.processPDF(doc, opts);
const buf = await doc.saveMemoryBuffer(
PDFNet.SDFDoc.SaveOptions.e_linearized
);
const buff = [];
buff.push(buf);
metadata.files.push({
originalName: file.originalname,
size: file.size,
compressedSize: Buffer.byteLength(buf),
});
metadata.buffer = [...metadata.buffer, ...buff];
} catch (err) {
throw new ServiceError(err);
}
}
I am confused and don’t have any clue about what to do next so can you guys help me out?
Please provide a link to a minimal sample where the issue is reproducible: