- Code Example
- Configuration Options
- Upload by URL
- Using Authentication
- Further details
The following tutorial shows you how to convert PDF files to HTML or SVG using a hosted BuildVu cloud API, such as:
- the IDRsolutions trial server
- the IDRsolutions cloud subscription server
- your own self-hosted BuildVu microservice
Using pip, install the idrcloudclient package with the following command:
pip install idrcloudclient
Here is a basic code example to convert PDF files to HTML or SVG. Configuration options and advanced features can be found below.
from IDRSolutions import IDRCloudClient client = IDRCloudClient('http://exampleURL.com/' + IDRCloudClient.BUILDVU) try: result = client.convert( # token='Token', # Required only when connecting to the IDRsolutions trial or cloud subscription servers input=IDRCloudClient.UPLOAD, file='/path/to/exampleFile.pdf' ) outputURL = result['downloadUrl'] client.downloadResult(results, 'path/to/output/dir') if outputURL is not None: print("Download URL: " + outputURL) except Exception as error: print(error)
The BuildVu API accepts a stringified JSON object containing key value pair configuration options to customise your conversion. The settings should be provided to the convert method. A full list of the configuration options to convert PDF files to HTML or SVG can be found here.
As well as uploading a local file you can also provide a URL which the BuildVu Microservice will download and then perform the conversion. To do this you should replace the input and file values in the convert method with the following.
If the BuildVu Microservice requires authentication, you will need to provide a username and password. These are provided by passing a variable named auth to the convert method as shown below.