Load from FTP
Leave feedback
NoteInstall 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);
}
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.