Convert PDF to MobiXML using Python

PDF to XML
Convert PDF to XML | PDF to XML converter online

Owing to the capabilities of preserving document formatting on major platforms, the PDF format is one of the popular file formats for data/information sharing. However, for a better reading experience, many users prefer eReaders and Mobi files is one of the eBook file formats created by the company Mobipocket for their Mobipocket Reader software. So let’s discuss the details on how to convert PDF to MobiXML using Python SDK.

PDF Conversion SDK

Aspose.PDF Cloud is a REST API providing the capabilities to create, process, and transform PDF files to a variety of supported formats. The API also provides the capabilities to load PDF documents and render the output in MobiXML format. So we are going to use Aspose.PDF Cloud SDK for Python which is available for download over PIP and GitHub repository. Please execute the following command on the terminal to install the latest version of SDK on the system.

pip install asposepdfcloud

After the installation, please create a free account over Aspose.Cloud dashboard using your GitHub or Google account, or simply Sign Up using Create a new Account option.

PDF to MobiXML using Python

In order to convert PDF files already available in cloud storage, please follow the instructions specified below

  • Firstly, create an instance of ApiClient while passing client credentials as arguments
  • Secondly, initialize PdfApi while passing the ApiClient object as an argument
  • Now call the put_pdf_in_storage_to_mobi_xml(..) method while passing input PDF and resultant .ZIP file name as arguments. Please note the output Mobixml will be saved as .ZIP archive.

Convert PDF to XML using cURL Command

In this section, we are going to export PDF to XML using cURL commands. The first step is to generate a JSON Web Token (JWT) based on your client credential details (specified over Aspose.Cloud dashboard). Please execute the following command to generate the JWT token.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=88d1cda8-b12c-4a80-b1ad-c85ac483c5c5&client_secret=406b404b2df649611e508bbcfcd2a77f" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once the JWT Token has been generated, please execute the following command to convert PDF to MobiXML format and save the resultant file as a .zip archive on Cloud storage.

curl -X PUT "https://api.aspose.cloud/v3.0/pdf/marketing.pdf/convert/mobixml?outPath=Converted.zip" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Conclusion

In the above article, we have focused on details on how to convert PDF to MobiXML using Python SDK as well as through cURL Commands. Please note that our Cloud SDKs are developed as per the MIT license and their complete code snippet can be downloaded for free. Similarly, you can download the complete source code of Aspose.PDF Cloud SDK for Python from GitHub. In case you encounter any issues or you have any further queries, you may also contact us via the free customer support forum.

You may also consider visiting the Developer Guide to learn more about other exciting features of the API.

Related Articles

We recommend visiting the following articles to learn about: