How to Convert DOCX/HTML to HTML/DOCX in Docker Container using Aspose.Words REST API

Can I buy ASPOSE words cloud API and host it on my premises so that I don’t have to send the files to you for converting them from docx/html to html/docx

@mosesm

Thanks for your interest in Aspose. We have recently released the first version of Aspose.Words Cloud at Docker hub. You can use it for self hosting and convert DOCX/HTML to HTML/DOCX. It can be started both in trial mode and licensed mode. After evaluating the product you can contact our sales team for purchase of a license and run a container in licensed mode.

Start in Trial mode

To get familiar with Aspose.Words Cloud Docker you can start a container in trial mode as follows. You need to set user and password for authenticating the API requests.

docker run -p 8080:80 -e "User=user_id" -e "Password=user_secret" -v "${pwd}/fonts:/fonts" -v "${pwd}/data:/data" aspose/words.cloud

Please note the trial mode (without a license specified) provides full product functionality, but it inserts an evaluation watermark at the top of the document, and limits the maximum document size to several hundred paragraphs.

Documentation and Code Samples

Aspose.Words Cloud documentation and SDK examples/code works with Aspose.Words Cloud Docker, but you just need to set base uri as per your Docker container.

Rest Client Example(cURL)

// Get access token
curl -X POST "http://localhost:8080/connect/token" -d "grant_type=client_credentials&client_id=[user_id]&client_secret=[user_secret]" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json"

// cURL example to upload file to storage(/data folder)
curl -X PUT "http://localhost:8080/v4.0/words/storage/file/Aspose.docx" -H "accept: application/json" -H "Authorization: Bearer [Access_Token]" -H "Content-Type:application/octet-stream" --data-binary C:/Temp/Aspose.docx

// cURL example to convert Word Document to PDF
curl "http://localhost:8080/v4.0/words/Aspose.docx/saveAs" -X PUT -H "Content-Type: application/json" -d "{"SaveFormat": "pdf","FileName": "Aspose.pdf",}" -H "Accept: application/json" -H "authorization: Bearer [Access_Token]"

SDK Example(Node.js)

const {WordsApi, ConvertDocumentRequest } = require("asposewordscloud");
var fs = require('fs');

wordsApi = new WordsApi("user_id", "user_secret", "http://localhost:8080");

var request = new ConvertDocumentRequest({
                    format: "html",
                    document: fs.createReadStream("Test.docx"),
                });
var outputFile = "C:/Temp/ConvertWordtoHTML_docker.html";
wordsApi.convertDocument(request).then((result) => {    
    console.log(result.response.statusCode);    
    console.log(result.body.byteLength);    
	fs.writeFileSync(outputFile, result.body);
}).catch(function(err) {
    // Deal with an error
    console.log(err);
});

Using API Explorer UI

After starting, you can use the Swagger UI at http://localhost:8080/swagger/ and start exploring the API. However, unfortunately authentication is not working in the first version as expected. We have logged a ticket WORDSCLOUD-1222 to fix it. Aspose.Words Cloud Docker working fine with REST Clients(e.g. cURL) and SDKs.

Please feel free to contact us for any further assistance.

1 Like

Thanks for the response. I will check it out and get back if I need any further clarifications.

1 Like

hi @tilal.ahmad,

Greetings.
I hosted the aspose docker on my premises from docker hub (Docker).
When I hit the “/” page I got the response as “Product is running” message.

I’m also able to see the swagger page. But when I hit any endpoint, I’m getting the error “500 - internal server error”. Please let me know how I can check the logs and what is going wrong. Please let me know if you need more information.

Best Regards
Moses

hi @tilal.ahmad,

A quick update. Good news. I was able to check the on-premises docker using postman and it was working.
Area for improvement: It was not working from swagger and as well as from the node.js sdk.

Best Regards
Moses

@mosesm

I have quick tests of swagger and the Node.js with my aspose-words Docker container and unable to notice any issue. If your container is working fine with postman then it should work with the Node.js as well. Please double check, are there more than one container running? And you are using aspose-words container instead of aspose.words. However, if the issue persists, then please confirm you have generated JWT token for authorization in swagger successfully and try to upload a file using UploadFile method in Swagger(http://localhost:xxxx/swagger/#/File/UploadFile) and share the screenshots here.

Swagger:

Node.js(code already shared in above post):

@mosesm

How are you running the Aspose.Word Docker Cloud Container? I am using Windows PowerShell, it shows complete logs of API Calls.

hi @tilal.ahmad

Greetings.
I hosted the docker in a centos box using the docker commands that was provided. But unable to see the logs. Is there any log file where I can see the logs?

Best Regards.

@mosesm

You may use Docker daemon log, for the purpose. Please check this stackoverflow post for details. We have also logged a ticket WORDSCLOUD-1237 for the support of logging in Aspose.Words Cloud Docker Container. We will keep you updated about the issue resolution progress within this forum thread.

1 Like

hi @tilal.ahmad.

Thanks for the response. Please can I know the probable release date for WORDSCLOUD-1237

Best Regards

@mosesm

We have completed the analysis of WORDSCLOUD-1237 ticket and concluded that docker standard logs fulfill the requirements. So please use Docker logs for the purpose.

To can run following command to view the logs:

docker logs container_id

1 Like

@mosesm

As an update, WORDSCLOUD-1222 is resolved in latest version of Aspose.Words Cloud Docker container. Now authentication in Swagger UI is working as expected.

A post was split to a new topic: How to enable swagger with Aspose.Slides Cloud docker containers?