In some cases it’s required to specify the document format manually to guarantee correct output produced by GroupDocs.Parser. The following are the cases when the document format must be specified manually:
Here are the steps to specify the document format for a Markdown document:
Create an instance of the LoadOptions class and pass the document format to the LoadOptions(FileFormat) constructor;
Create an instance of the Parser class with these options and call any method.
The following example shows how to specify the document format for a Markdown document loaded from a stream:
constfs=require('fs');constgroupdocs=require('@groupdocs/groupdocs.parser');groupdocs.readDataFromStream(fs.createReadStream('sample.md'),(stream)=>{// Create an instance of Parser class for markdown document
constparser=newgroupdocs.Parser(stream,newgroupdocs.LoadOptions(groupdocs.FileFormat.Markup));try{// Check if text extraction is supported
if(!parser.getFeatures().isText()){console.log("Text extraction isn't supported.");}else{constreader=parser.getText();try{// Print the document text
console.log(reader.readToEnd());}finally{reader.close();}}}finally{parser.close();}process.exit(0);});
A stream has no file name, so the file format can’t be detected by the extension. FileFormat.Markup tells the parser to process the stream as a Markdown document.
More resources
Free online document parser App
Along with the full-featured library we provide simple but powerful free Apps.
You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our Free Online Document Parser App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.