Load document from local disk

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-parser -- dnx GroupDocs.Parser.Mcp --yes
Folders, licensing and more →

GroupDocs.Parser for Node.js via Java provides the functionality to extract data from documents on the local disk. Pass the file path to the Parser constructor.

The following example shows how to load the document from the local disk:

const groupdocs = require('@groupdocs/groupdocs.parser');

// Set the file path
const filePath = 'sample.pdf';
// Create an instance of Parser class with the file path
const parser = new groupdocs.Parser(filePath);
try {
  // Extract a text into the reader
  const reader = parser.getText();
  // If text extraction isn't supported, a reader is null
  if (reader === null) {
    console.log("Text extraction isn't supported");
  } else {
    try {
      // Print a text from the document
      console.log(reader.readToEnd());
    } finally {
      reader.close();
    }
  }
} finally {
  parser.close();
}
process.exit(0);

A relative path is resolved against the current working directory of the Node.js process. Use path.join(__dirname, 'sample.pdf') to resolve the path against the script folder.

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.