Load document from URL

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.Conversion 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-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

The following code snippet shows how to convert a document from an URL:

const fetch = require('node-fetch');

async function fetchUrl(url) {
    try {
        const response = await fetch(url);
        
        if (!response.ok) {
            throw new Error(`URL fetch error: ${response.statusText}`);
        }

        const stream = response.body;
        return stream;
    } catch (error) {
        throw new Error(error);
    }
}

const url = 'https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java/blob/master/Examples/Resources/SampleFiles/sample.docx?raw=true'

try {
    const stream = await fetchUrl(url)
    const converter = new groupdocs.conversion.Converter(stream);
    const convertOptions = new groupdocs.conversion.PdfConvertOptions();
    converter.convert('loadDocumentFromUrl.pdf', convertOptions);

}catch(e){
    throw new Error(e);
}