Changes filename using js, but the old filename persists in download

This commit is contained in:
Dimitrios Kaitantzidis
2023-10-08 18:59:43 +03:00
parent f3ddf18a23
commit a1b7aaddb8
2 changed files with 35 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ class PdfContainer {
this.rotateElement = this.rotateElement.bind(this);
this.rotateAll = this.rotateAll.bind(this);
this.exportPdf = this.exportPdf.bind(this);
this.updateFilename = this.updateFilename.bind(this);
this.pdfAdapters = pdfAdapters;
@@ -28,6 +29,9 @@ class PdfContainer {
window.addPdfs = this.addPdfs;
window.exportPdf = this.exportPdf;
window.rotateAll = this.rotateAll;
const filenameInput = document.getElementById('filename-input');
filenameInput.onkeyup = this.updateFilename;
}
movePageTo(startElement, endElement, scrollTo = false) {
@@ -202,10 +206,20 @@ class PdfContainer {
// Download the file
const downloadLink = document.createElement('a');
downloadLink.href = url;
console.log('filename before download ' + this.filename);
downloadLink.download = this.fileName ? this.fileName : 'managed.pdf';
downloadLink.click();
}
}
updateFilename() {
const filenameInput = document.getElementById('filename-input');
const filenameParagraph = document.getElementById('filename');
console.log('updatedFilename fired ' + filenameInput.value);
this.filename = filenameInput.value;
filenameParagraph.innerText = this.filename;
}
}
export default PdfContainer;