lexguard-backend / src /services /pdfParser.js
github-actions[bot]
Deploy to Hugging Face
b921752
Raw
History Blame Contribute Delete
426 Bytes
const pdfParse = require('pdf-parse');
const fs = require('fs');
/**
* Extracts raw text from a PDF file using pdf-parse.
* @param {string} filePath - Absolute path to the PDF file.
* @returns {Promise<string>} - Raw extracted text.
*/
const parsePdf = async (filePath) => {
const dataBuffer = fs.readFileSync(filePath);
const data = await pdfParse(dataBuffer);
return data.text;
};
module.exports = { parsePdf };