Free Support Forum - aspose.cloud

How to get base64 images in DOCX to HTML Conversion using Aspose.Words Cloud API?

Hello,
I have a question.
Currently I’m try get images from my document (format .docx). What variants I have?
I saw in Java library we can use set parameter and after we can get base64 format our image into html the document. Can I get html of my document and images base64 format together?

Thank you, Anatoliy

@Anatoliy

Thanks for your inquiry. You can use imageData API for extracting the images from Word document. Please check sample cURL command for the purpose.

curl -X GET "https://api.aspose.cloud/v4.0/words/ImageTest.docx/drawingObjects/0/imageData" -H "accept: application/json" -H "authorization: Bearer [Access_Token]" --output C:/Temp/TestImage.png

Thank you for you answer, but it don’t resulve my issue. I asked, can I set any parameter to I get image via base 64 format in my output html. If not, than I should know how get coordinates of the image in my document.

@Anatoliy

Thanks for your feedback. Please check saveAs API for converting Word documents to HTML with detail setting by using HtmlSaveOptions. You need to use ExportImagesAsBase64 property as follows:

-d "{ "SaveFormat": "html", "FileName": "test.html", “ExportImagesAsBase64”: true}"

Thank you for your feedback.
I tried save new file with same options, but html file as result not contains images in base64 format.
Also in your cloud api, by my opinion, work with “saveOptionsData”, that less than “htmlSaveOptionsData” object. Can show example, how you get html file with images in base64 format?
Thank you

@Anatoliy

Thanks for your feedback. Please check following sample cURL command used for DOCX to HTML conversion with base64 image and sample output.

curl -X PUT "https://api.aspose.cloud/v4.0/words/ImageTest.docx/saveAs" -H "accept: application/json" -H "authorization: Bearer [JWT-AccessToken]" -H "Content-Type: application/json" -d "{"SaveFormat": "html","FileName": "test.html","ExportImagesAsBase64": true}"

Furthermore, please note we have recently released V4 API version of Aspose.Words Cloud. We have used V4 API version for the subjected example.
test.zip (86.9 KB)