Convert documents in various formats (pdf, doc, rtf) to plain text.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('file-conversion/doc-to-text@1.0.0');
// Use the profile
const result = await profile
.getUseCase('ConvertDocumentToText')
.perform({
fileName: 'big-bang.pdf',
content: '<BinaryData>'
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"fileName": "big-bang.pdf",
"content": "<BinaryData>"
}
{
"text": "The Big Bang event is a physical theory that describes how the universe expanded from an initial state of high density and temperature. Various cosmological models of the Big Bang explain the evolution of the observable universe from the earliest known periods through its subsequent large-scale form."
}