PDF offers unique advantages over other file formats as it can transform business workflows, official documents in a format which preserves the layout/formatting when viewed on any platform. It ensures all viewers see the document as intended, regardless of the native application, viewer, operating system, or the device being used. But, Mobi(MobiXML) format is self explanatory and refers to eBook MobiXML Standard format. It is supported by almost all modern e-readers specifically, the mobile devices with low bandwidth. So in this article, we are going to explore the details on How to convert PDF to MobiXML using REST API.
PDF Processing API
In order to programmatically manipulate PDF file, we have created a REST based solution named Aspose.PDF Cloud. It enables you to create, edit, manipulate and convert PDF documents to a plethora of supported formats. Now as we need the PDF conversion capabilities in Java application, so we need to add the reference of Aspose.PDF Cloud SDK for Java in our Java application by including following details in pom.xml (maven build type project).
<repositories> <repository> <id>aspose-cloud</id> <name>artifact.aspose-cloud-releases</name> <url>http://artifact.aspose.cloud/repo</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-cloud-pdf</artifactId> <version>21.11.0</version> <scope>compile</scope> </dependency> </dependencies>
The next is to obtain your client credentials from Cloud Dashboard. If you are not already registered, please register using valid email address and fetch your personalized credentials.
PDF to Mobi Converter in Java
In order to develop a PDF to Mobi converter using Java, please follow the instructions specified below. Please note that these steps convert the PDF document (located on Cloud storage) to MOBIXML format and then uploads the resultant ZIP archive to the cloud storage.
- Create an instance of PdfApi where we pass the personalized credentials as arguments
- Read the input PDF using File object and upload it to cloud storage using uploadFile(…) method of the PdfAPi class
- Create a string object holding the name of resultant MobiXML file
- Finally, call putPdfInStorageToMobiXml(…) method to convert the PDF to Mobi online and save the output to cloud storage
PDF to Mobi Kindle using cURL Commands
Another option to access the REST APIs is via cURL commands. So in this section, we are going to convert the PDF to Mobi Kindle format using the cURL commands. Now, as a prerequisite, we need to first generate a JWT access token (based on client credentials) using the following command.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
Now execute the following command, which loads the input PDF file from Cloud storage and saves the resultant MobiXML to local drive.
curl -v -X GET "https://api.aspose.cloud/v3.0/pdf/input.pdf/convert/mobixml" \ -H "accept: multipart/form-data" \ -H "authorization: Bearer <JWT Token>" \ -o "Resultant.mobi"
In order to view the Mobi files online, please try using our Free Mobi viewer.
We have gone through all the necessary steps for utilizing the REST API to convert PDF to Mobi (MobiXML) format. You may have observed that the complete process has been simple and straightforward. So either you convert a single PDF or perform a batch processing against multiple PDF files. We also recommend you to explore the Product Documentation which contains the information regarding all the exciting features currently supported by the API.
Furthermore, if you desire to access the source code of the Cloud SDK, it is available on GitHub (published under MIT license). Lastly, in case you encounter any issue while using the API, please feel free to contact us via free Product Support Forum.
Please visit the following links to learn more about: