Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active January 24, 2023 21:25
Convert PDF to Mobi in Java
A step-by-step guide to convert PDF to Mobi using Java
// for more examples, please visit https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java/tree/master/Examples/src/main/java/com/aspose/asposecloudpdf/examples
try
{
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/
String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";
// create an instance of PdfApi
PdfApi pdfApi = new PdfApi(clientSecret,clientId);
// name of input PDF document
String name = "input.pdf";
// read the content of input PDF file
File file = new File("/Users/Downloads/"+name);
// upload PDF to cloud storage
pdfApi.uploadFile("input.pdf", file, null);
// resultant file name
String resultantFile = "resultant.mobi";
// call the API for PDF to MobiXML conversion. The resultant file is saved in cloud storage
pdfApi.putPdfInStorageToMobiXml("input.pdf", resultantFile, null, null);
// print success message
System.out.println("PDF to Mobi conversion successful !");
}catch(Exception ex)
{
System.out.println(ex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment