How to Convert PDF to MobiXML with Java REST API

This short tutorial shows you how to convert PDF to MobiXML with Java REST API in the cloud. In order to export PDF to MobiXML format, we’re using Aspose.PDF for Java Cloud SDK. If you would like PDF to MobiXML Conversion in Java Low Code API then this can be achieved by using the below steps and code.

Prerequisite

Steps to Convert PDF to MobiXML in Java REST API

  1. Set Client ID and Client Secret for the API
  2. Create an object of pdfApi class with client credentials
  3. Specify input and output files
  4. Read input PDF file and upload to cloud storage
  5. Create an object of pdfApi with input and output file formats
  6. Call putPdfInStorageToMobiXml method to Convert PDF to MobiXML using REST API
  7. Save the output MobiXML file on local disk

Code for PDF to MobiXML Conversion in Java Low Code API

String ClientID = Client.getID(); //replace Client.getID() with your own client ID here
String ClientSecret = Client.getSecret(); //replace3 Client.getSecret() with your own client secret here
try {
ApiClient apiClient = new ApiClient();
apiClient.setAppKey(ClientSecret);
apiClient.setAppSid(ClientID);
PdfApi pdfApi = new PdfApi(apiClient);
String inputFile = "PDFtoMobi.pdf";
String outputFile = "PDFtoMobi.mobi";
String folder = "Temp";
String format = "Mobi";
// Upload file to cloud storage
File file = new File("C:/Temp/" + inputFile);
pdfApi.uploadFile(folder + "/" + inputFile, file, null);
pdfApi.putPdfInStorageToMobiXml(inputFile, folder + '/' + outputFile, folder, null);
// Download output file from Cloud Storage
File downloadResponse = pdfApi.downloadFile(folder + "/" + outputFile, null, null);
File dest = new File("C:/Temp/" + outputFile);
Files.copy(downloadResponse.toPath(), dest.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
System.out.println(e.getMessage());
}

The code snippet given on this page assists you to convert PDF to MobiXML with Java REST API. You merely need to upload PDF file with the help of the Aspose.PDF REST API SDK for Java and download output MobiXML file to save it locally by using Aspose conversion API online.

This PDF to MobiXML Conversion feature can be put to use with any no code or low code apps on any operating system.

You may also check out another similar feature at the following page: How to Convert PDF to XLSX with Java REST API

 English