Saltar al contenido principal

Usar OCR

Totalum permite usar OCR para extraer texto de imágenes y documentos pdf.

What happens if you are not programming in javascript?

If you are not programming in javascript, you can use the api directly, see TOTALUM API DOCUMENTATION

If you are programming in javascript, you can use the totalumSdk

Note: If you use totalumSdk inside a totalum plugin, you don't need to authenticate, you can start using totalum sdk functions like this: modules.totalumSdk.ocr.ocrOfImage(fileName); etc...

Si tienes dudas de como instalar y usar TotalumSdk mira la documentación: Instalación SDK de Totalum, y Uso del SDK

Ejemplo de como usar el endpoint de ocr con el SDK de Totalum:

get OCR of an image (get the text of an image)


// si ya tienes el archivo subido a totalum, puedes usar el nombre del archivo subido para extraer el texto
const fileName = 'your_file_name_id.your-image-extension'; // replace 'your_file_name' with the name of your file, replace .png with the extension of your image
const resultOcr = await totalumClient.files.ocrOfImage(fileName);
const ocrResult = result.data.data;
// ocrResult.text will contain all text of the image
// ocrResult.fullDetails will contain all details of the image, like the language, in the position of the text, etc.


// si no tienes el archivo subido a totalum, primero tendrás que subirlo y luego extraer el texto
const fileName = 'your_file_name_id.your-image-extension'; // replace 'your_file_name' with the name of your file, replace .png with the extension of your image
const file = yourFileBlob // replace yourFile with your file object binary blob (in blob format)
const fileFormData = new FormData();
fileFormData.append('file', file, fileName);
const result = await totalumClient.files.uploadFile(fileFormData);
const fileNameId = result.data.data;

const result = await totalumClient.files.ocrOfImage(fileNameId);
const ocrResult = result.data.data;
// ocrResult.text will contain all text of the image
// ocrResult.fullDetails will contain all details of the image, like the language, the position of the text, etc

get OCR of a pdf (get the text of a pdf)


// si ya tienes el archivo subido a totalum, puedes usar el nombre del archivo subido para extraer el texto
const fileName = 'nombre-del-archivo.pdf'
const resultOcr = await totalumClient.files.ocrOfImage(fileName);
const ocrResult = result.data.data;
// ocrResult.text will contain all text of the pdf
// ocrResult.fullDetails will contain all details of the pdf, like the language, in which page is the text, the position of the text, etc.



// si no tienes el archivo subido a totalum, primero tendrás que subirlo y luego extraer el texto
const fileName = 'your_file_name.png'; // replace 'your_file_name' with the name of your file, replace .png with the extension of your file
const file = yourFileBlob // replace yourFile with your file object binary blob (in blob format)
const fileFormData = new FormData();
fileFormData.append('file', file, fileName);
const result = await totalumClient.files.uploadFile(fileFormData);
const fileNameId = result.data.data;


const result = await totalumClient.files.ocrOfPdf(fileNameId);
const ocrResult = result.data.data;
// ocrResult.text will contain all text of the pdf
// ocrResult.fullDetails will contain all details of the pdf, like the language, in which page is the text, the position of the text, etc.