= totalPages) { xmlContent += ''; // Create a temporary link element to download the XML var link = document.createElement('a'); link.href = 'data:text/xml;charset=utf-8,' + encodeURIComponent(xmlContent); link.download = 'converted.xml'; link.click(); } else { convertPageToXML(pageNumber + 1); } }); }); }; convertPageToXML(1); }); }; fileReader.readAsArrayBuffer(file); }