1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-05 07:20:12 +01:00

Change in name works.

This commit is contained in:
Dimitrios Kaitantzidis 2023-10-08 19:57:19 +03:00
parent a1b7aaddb8
commit 323745e61f

View File

@ -3,11 +3,13 @@ class PdfContainer {
pagesContainer; pagesContainer;
pagesContainerWrapper; pagesContainerWrapper;
pdfAdapters; pdfAdapters;
downloadLink;
constructor(id, wrapperId, pdfAdapters) { constructor(id, wrapperId, pdfAdapters) {
this.fileName = null; this.fileName = null;
this.pagesContainer = document.getElementById(id) this.pagesContainer = document.getElementById(id)
this.pagesContainerWrapper = document.getElementById(wrapperId); this.pagesContainerWrapper = document.getElementById(wrapperId);
this.downloadLink = null;
this.movePageTo = this.movePageTo.bind(this); this.movePageTo = this.movePageTo.bind(this);
this.addPdfs = this.addPdfs.bind(this); this.addPdfs = this.addPdfs.bind(this);
this.addPdfsFromFiles = this.addPdfsFromFiles.bind(this); this.addPdfsFromFiles = this.addPdfsFromFiles.bind(this);
@ -15,6 +17,7 @@ class PdfContainer {
this.rotateAll = this.rotateAll.bind(this); this.rotateAll = this.rotateAll.bind(this);
this.exportPdf = this.exportPdf.bind(this); this.exportPdf = this.exportPdf.bind(this);
this.updateFilename = this.updateFilename.bind(this); this.updateFilename = this.updateFilename.bind(this);
this.setDownloadAttribute = this.setDownloadAttribute.bind(this);
this.pdfAdapters = pdfAdapters; this.pdfAdapters = pdfAdapters;
@ -204,14 +207,26 @@ class PdfContainer {
window.open(url, '_blank'); window.open(url, '_blank');
} else { } else {
// Download the file // Download the file
const downloadLink = document.createElement('a'); this.downloadLink = document.createElement('a');
downloadLink.href = url; this.downloadLink.id = 'download-link';
console.log('filename before download ' + this.filename); this.downloadLink.href = url;
downloadLink.download = this.fileName ? this.fileName : 'managed.pdf'; console.log('downloadLink.href ' + this.downloadLink.href);
downloadLink.click(); // downloadLink.download = this.fileName ? this.fileName : 'managed.pdf';
// downloadLink.download = this.fileName;
this.downloadLink.setAttribute('download', this.filename ? this.fileName : 'managed.pdf');
this.downloadLink.setAttribute('target', '_blank');
this.downloadLink.onclick = this.setDownloadAttribute;
console.log('downloadLink download ' + this.downloadLink.download);
this.downloadLink.click();
} }
} }
setDownloadAttribute() {
console.log('inside setDownloadAttribute ' + this.filename);
this.downloadLink.setAttribute("download", this.filename);
console.log('downloadLink download 2 ' + a.download);
}
updateFilename() { updateFilename() {
const filenameInput = document.getElementById('filename-input'); const filenameInput = document.getElementById('filename-input');
const filenameParagraph = document.getElementById('filename'); const filenameParagraph = document.getElementById('filename');