Load from FTP

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);
}