Free Support Forum - aspose.cloud

Convert Word PPT and EXCEL File formats to PDF in JAVA using Aspose Cloud APIs

My company is evaluating Aspose Cloud APIs for converting documents from various formats to pdf.

Can
you provide a complete snippet in Java to upload a file from local
computer to the cloud storage, then call the conversion APIs to convert
to PDF?

Please do not send me links to various samples scattered in the online documentation. They are quite confusing and incomplete.

Thanks!

Hi,

You can download Aspose Cloud SDK for Java from https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Java which contains the complete code to upload and convert files e.g. you can use the following code after downloading the SDK to upload any file (Excel file in this case) and convert it PDF.

AsposeApp.setAppSID(“77**************”);

AsposeApp.setAppKey(“23*********”);

com.aspose.cloud.common.Product.setBaseProductUri(http://api.aspose.com/v1.1);

try {

Folder folder =new Folder();

folder.UploadFile(“C:\Sample.xlsx”, “”);

//Create Converter
object

com.aspose.cloud.cells.Converter
converter = new com.aspose.cloud.cells.Converter(“Sample.xlsx”);

<?xml:namespace prefix = “o” ns = “urn:schemas-microsoft-com:office:office” /><o:p> </o:p>

//Convert Workbook

converter.Save(“D:\Output.pdf”, SaveFormat.PDF);

<o:p> </o:p>

System.out.println(“Done”);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();<o:p></o:p>

}

Upload file code will remain the same however you can use Converter classes from words, slides, cells and pdf folders to convert Word, PowerPoint, Excel and PDF files respectively.

Please let us know if you still find any issue in using the examples.