Convert XSLX to PDF in Python with WebDAV Protocol Storage

I am a new potential user for GroupDocs as I am interested in using Python to convert xlsx documents to pdf.

In order for this to work with GroupDocs, I need to setup a storage space. I have seen the options that are available, just wondered if there is an option either now or in the near future to use my own cloud storage that can use the WebDAV protocol. I currently use it to backup some of my other systems automatically.

Thanks in Advance

@jkarim

I am afraid currently we do not support WebDAV storage. However, in addition to groupdocs.cloud hosted GroupDocs.Conversion Cloud API, you can host GroupDocs.Conversion Cloud API yourself using Docker container. And it allows you to use your own cloud storage and proceed accordingly. Hopefully, it will help you to accomplish the task.

I have setup the docker image on my test system here and can access the Swagger UI and Web Request returns status code 200. All good so far.

To test my Python application, I apparently need the APP KEY and APP SID. If I go to create these via the dashboard, I do not see the option for self hosted storage, so how would I go about getting the keys or a trial license?

Where can I check the pricing for the self-hosted version.

@jkarim

You can use GroupDocs.Conversion Cloud SDK for Python and documentation with your docker image for testing.

The SDKs require authentication, so you need to set predefined CLIENT_ID/CLIENT_SECRET parameters when running the GroupDocs.Conversion Cloud Docker image. Please check the Enable Authentication section from Docker Hub. And secondly, you need to set base_url in the code as per your docker image configuration as follows.

....
....

client_id = "clientid"
client_key = "clientkey"
base_url="http://localhost:8080"
configuration = groupdocs_conversion_cloud.Configuration(client_id, client_key)
configuration.api_base_url=base_url
....
....

The pricing plan for self-hosted Docker image is the same as our cloud based service except for storage methods(APIs) are not charged in Docker image.

I have got my docker container working, and am looking into create the relevant api calls from python, all your examples are based on using your own cloud service, not a locally hosted service.

When I start the docker I still get:

“License” parameters are omitted, the app works in trial mode.

Where do I get this license from?

I have already generated and applied the clients. Using ‘Swagger’ on the local instance does work, however because it thinks it is in evaluation mode, I can convert any of the documents that I want to.

@jkarim

As stated on the self-hosting page, you need to contact our sales team for license keys. However, in trial mode you can check all the functionalities but it add a watermark on the documents.

To receive your license keys please contact the GroupDocs Cloud sales team.

Furthermore, about the issue using GroupDocs.Conversion Cloud SDK for Python with your Docker image. Please share your sample code and the error message. We will look into it and guide you accordingly.

Hi,
I have got a way bit further, but just stuck on try to convert documents. I have successfully managed to set a request via Python to my hosted system, which sends back data conversion formats for xlsx.

However, I am now stuck at a point where I am sending a request to perform a conversion of a document to pdf, just a simple 1 page with the words ‘testing’, however the response I get back, says that I am not specifying the output format, however I have specified the output format, as in the Python code below:

convert_request_data = {“storageName”: “data”,
“filePath”: “Testing.xlsx”,
“format”: “pdf”,
“loadOptions”: {},
“convertOptions”: {
“fromPage”: 0,
“pagesCount”: 0,
“pages”: [1]},
“outputPath”: “Testing.pdf” }

convert_request_data_json = json.dumps(json.dumps(convert_request_data))

groupdocs_convert_reponse = requests.put(convert_request_url, headers=convert_request_headers, data=convert_request_data_json)

The message I get back is as follows:

b’{“error”:{“code”:“errorInvalidInputData”,“message”:“Conversion format is not specified”,“description”:“Operation Failed. The input data is not valid.”,“innerError”:{“requestId”:“afb9583e-5c36-40bd-81c8-0cee630bab83”,“date”:“2022-03-06T08:55:32.9907476Z”}}}’

The request body consists of:

“{“storageName”: “data”, “filePath”: “Testing.xlsx”, “format”: “pdf”, “loadOptions”: {}, “convertOptions”: {“fromPage”: 0, “pagesCount”: 0, “pages”: [1]}, “outputPath”: “Testing.pdf”}”

Any guidance much appreciated.

I shall contact the sales team for a license code.

@jkarim

It seems you are trying to use ConvertDocumentDirect API method to convert XLSX to PDF from your local drive instead of cloud storage. Please note ConvertDocumentDirect does not support LoadOptions and ConvertOptions. Please check the following documentation article for details.

Thanks, I have got the without storage conversion working, however is there a way of specifying where the converted files will be stored, instead of the default folder ‘…\AppData\Local\Temp\2’,

Also the converted filename contains ‘;’ at the end of the name, eg when converting file Test.xlsx the converted file is called Test.pdf;

Is there anywhere this could be changed?

@jkarim

You may use shutil package to save the response to the local drive as follows.

# Import module
....
from shutil import copyfile
....
....

# Convert
....    
copyfile(groupdocs_convert_reponse, 'C:/Temp/sample.pdf')

Please share your sample working code with us. We will look into it and will guide you accordingly.