Use pdf2md as a JavaScript library
masterYou can integrate pdf2md into your Node.js application to convert PDF buffers into Markdown text. The library accepts a PDF buffer and returns a Promise that resolves with the converted Markdown string.
Note: The example usage requires a callbacks argument in the function signature, though the implementation details of these callbacks are not specified in the README.
const path = require('path');
const fs = require('fs')
const pdf2md = require('@opendocsg/pdf2md')
const pdfBuffer = fs.readFileSync(filePath)
pdf2md(pdfBuffer, callbacks)
.then(text => {
let outputFile = allOutputPaths[i] + '.md'
console.log(`Writing to ${outputFile}...`)
fs.writeFileSync(path.resolve(outputFile), text)
console.log('Done.')
})
.catch(err => {
console.error(err)
})