You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with PDF where I need to extract text but, any of text extracting method is not working.
const { PDFDocument } = require('pdf-lib');
const fs = require('fs');
async function removetext(inputPath, pageNumber) {
// Read the input PDF file
const pdfDoc = await PDFDocument.load(fs.readFileSync(inputPath));
// Get the page that you want to extract text from
const page = pdfDoc.getPage(pageNumber);
// Get the text content of the page
const textStream = page.getTextContent();
// Get the text as a string
const text = textStream.getText();
return text;
}
// Call the extractText function to extract text from page 1 of the input.pdf file
const text = removetext('fileupload.pdf', 1);
// Print the extracted text to the console
console.log(text);
error : TypeError: page.getTextContent is not a function TypeError: page.extractText is not a function
is there any replacement in of function in new realse??
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am working with PDF where I need to extract text but, any of text extracting method is not working.
error : TypeError: page.getTextContent is not a function
TypeError: page.extractText is not a function
is there any replacement in of function in new realse??
Beta Was this translation helpful? Give feedback.
All reactions