I'm utilizing the docxtemplater library in JavaScript to generate a docx document.
It works perfectly on desktop browsers, but I'm encountering issues on iOS.
When attempting to download or open the document on iOS, a new tab opens in the browser displaying a URL like:
blob:http://mylocalServer/987788-3524-33iuhih3334434434
Unfortunately, I can't view or download the document in this new tab.
Is there a solution to retrieve the docx document on iOS?
Below is the JavaScript code for creating the docx document:
out=doc.getZip().generate({type:"blob"});
// Provide a name for the output word document
var outputName = "test.docx" ;
saveAs(out,outputName);
The saveAs function is invoked in the FileSaver.js file:
On iOS, the following code is executed after the action:
fs_error = function() {
// avoid unnecessary creation of object URLs
if (blob_changed || !object_url) {
object_url = get_URL().createObjectURL(blob);
}
if (target_view) {
target_view.location.href = object_url;
} else {
var new_tab = view.open(object_url, "_blank");
if (new_tab == undefined && typeof safari !== "undefined") {
//Apple does not allow window.open, see http://bit.ly/1kZffRI
view.location.href = object_url
}
}
filesaver.readyState = filesaver.DONE;
dispatch_all();
revoke(object_url);
}