mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2024-11-04 23:10:11 +01:00
Changes filename using js, but the old filename persists in download
This commit is contained in:
parent
f3ddf18a23
commit
a1b7aaddb8
@ -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;
|
||||
|
@ -20,6 +20,15 @@
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6" style="text-align: center">
|
||||
<div id="global-buttons-container" class="d-flex align-content-center justify-content-center">
|
||||
<div class="form-group">
|
||||
<label for="filename-input">Filename</label>
|
||||
<input type="text" class="form-control" id="filename-input" placeholder="filename" onkeyup="(e) => updateFilename(e)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p>Final name of file: </p><p id="filename"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="global-buttons-container">
|
||||
|
||||
<button class="btn btn-primary" onclick="addPdfs()">
|
||||
@ -29,6 +38,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
|
||||
<button class="btn btn-secondary enable-on-file" onclick="rotateAll(-90)" disabled>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z" />
|
||||
@ -114,6 +124,14 @@
|
||||
#global-buttons-container > * {
|
||||
padding: 0.6rem 0.75rem;
|
||||
}
|
||||
#global-buttons-container input {
|
||||
background-color: #323948;
|
||||
caret-color: #ffffff;
|
||||
color: #ffffff;
|
||||
}
|
||||
#global-buttons-container input::placeholder {
|
||||
color: #ffffff;
|
||||
}
|
||||
#global-buttons-container svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
|
Loading…
Reference in New Issue
Block a user