The following code snippet shows how to convert a document from FTP:
packagecom.groupdocs.conversion.examples.advanced_usage.loading.loading_documents_from_different_sources;importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.examples.Constants;importcom.groupdocs.conversion.exceptions.GroupDocsConversionException;importcom.groupdocs.conversion.options.convert.PdfConvertOptions;importorg.apache.commons.net.ftp.FTPClient;importjava.io.File;importjava.io.InputStream;/**
* This example demonstrates how to convert document downloaded from FTP.
*/publicclassLoadDocumentFromFtp{publicstaticvoidrun(){Stringserver="ftp.example.com";StringconvertedFile="C:\\output\\converted.pdf";StringfilePath="ftp://localhost/sample.doc";try{Converterconverter=newConverter(getFileFromFtp(server,filePath));PdfConvertOptionsoptions=newPdfConvertOptions();converter.convert(convertedFile,options);}catch(Exceptione){thrownewGroupDocsConversionException(e.getMessage());}System.out.println("\nSource document converted successfully.\nCheck output in "+convertedFile);}privatestaticInputStreamgetFileFromFtp(Stringserver,StringfilePath)throwsException{FTPClientclient=newFTPClient();client.connect(server);returnclient.retrieveFileStream(filePath);}}
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.