Load from FTP

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.Viewer 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-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →
Note
Install the Apache Commons Net library to use the FTP client.

The following code snippet shows how to load a document from FTP:

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
// ...

FTPClient ftpClient = new FTPClient();

ftpClient.connect(server, 21);
ftpClient.login(ftpUser, ftpPassword);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);

try (final InputStream inputStream = ftpClient.retrieveFileStream(remoteFile);
     Viewer viewer = new Viewer(inputStream)) {
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
    viewer.view(viewOptions);
}