Tools to Capture and Convert the Web
GrabzIt's Online Community

Changing the DOCX result in JavaScript

Ask questions on how to capture or convert web pages or HTML into images, CSV, PDF or DOCX documents as well on how to convert videos into animated GIF's using our API.

Hi,

I am using the JavaScript code to export html into the Docx.


is there any way that i can manipulate the response before downloading or i could get the file in response so i could manipulate it as per my need then download.

GrabzIt("Application Key").ConvertHTML(data ,{"onfinish": function(response){
alert(response);
},
"format": "docx"}).Create();

As here is a onfinish event but here i get only id not any response file response

if we have something like this will be helped.

Asked by GrabzIt Support on the 25th of June 2019

You can get the response by using the DataURI method, which returns the response in a base64 encoded format.

However as the DOCX format is essentaially a ZIP file made up of a number of XML files covering things like content, styles etc. You may be better off using a server side language if you want to try and manipulate it.

Answered by GrabzIt Support on the 25th of June 2019

Hi ,

After using the DataUri callback method i got the below response, but is there any way to convert it into the file format so i could download it after manipulation

data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,
UEsDBBQAAAAIABlr2U5ryYMnqhgAAPTYAAARABwAd29yZC9kb2N1bWVudC54bWwgohgA

Thanks

 

 

 

Answered by GrabzIt Support on the 25th of June 2019

Remember you are trying to do this in JavaScript so this severley limits what you can do if you are not willing to use a server-side programming language.

You have two options:

The first option is to put the Data URI in a HTML link and add a download attribute. When someone clicks on the link it will download.

Otherwise you can upload this Data URI to a server-side programming language. Manipulate it there then re-download it from by calling a creating a new web service for the purpose and calling it from the client side.

Answered by GrabzIt Support on the 25th of June 2019

Thanks for your replying.

Actually, i just want to keep the dlownloaded file into some folder, which will create on fly once i get the response by DataUri call back method 

 

Thanks

Charanjit Singh

 

Answered by Charanjit Singh on the 25th of June 2019