-
Notifications
You must be signed in to change notification settings - Fork 17
Functions:documentParser
Emiel Wit edited this page Jan 18, 2024
·
8 revisions
The documentParser function is an asynchronous function that takes in DocumentParserArguments as a parameter and returns a Promise that resolves to DocumentParserResult. It is used to parse a document and extract the text content from it.
interface DocumentParserArguments {
document: string;
parserOptions?: {
forceImage?: boolean;
density?: number;
};
}
interface DocumentParserResult {
result: string;
}A Promise that resolves to DocumentParserResult which is an object that contains the result which is the extracted text from the parsed document.
const isFileProperty = (value) =>
value && typeof value === 'object' && 'url' in value;
const parseDocument = async ({ document, density, forceImage }) => {
const url = isFileProperty(document) ? document?.url : document;
const { result } = await documentParser({
document: url,
parseOptions: { density, forceImage },
});
return {
result,
};
};
export default parseDocument;- Getting started
- Page Builder Components
- Action Functions
- [deprecated] CustomFunctions