Added page counts to merge pdf tool (#1986)
* Added page counts to merge pdf tool * used page and pages in en_GB and hindi properties file
This commit is contained in:
@@ -11,7 +11,7 @@ document.getElementById("fileInput-input").addEventListener("change", function (
|
||||
/**
|
||||
* @param {FileList} files
|
||||
*/
|
||||
function displayFiles(files) {
|
||||
async function displayFiles(files) {
|
||||
const list = document.getElementById("selectedFiles");
|
||||
|
||||
while (list.firstChild) {
|
||||
@@ -19,11 +19,16 @@ function displayFiles(files) {
|
||||
}
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const pageCount = await getPDFPageCount(files[i]);
|
||||
const pageLabel = pageCount === 1 ? pageTranslation : pagesTranslation;
|
||||
const item = document.createElement("li");
|
||||
item.className = "list-group-item";
|
||||
item.innerHTML = `
|
||||
<div class="d-flex justify-content-between align-items-center w-100">
|
||||
<div class="filename">${files[i].name}</div>
|
||||
<div class="page-info">
|
||||
<span class="page-count">${pageCount} ${pageLabel}</span>
|
||||
</div>
|
||||
<div class="arrows d-flex">
|
||||
<button class="btn btn-secondary move-up"><span>↑</span></button>
|
||||
<button class="btn btn-secondary move-down"><span>↓</span></button>
|
||||
@@ -37,6 +42,13 @@ function displayFiles(files) {
|
||||
attachMoveButtons();
|
||||
}
|
||||
|
||||
async function getPDFPageCount(file) {
|
||||
const blobUrl = URL.createObjectURL(file);
|
||||
const pdf = await pdfjsLib.getDocument(blobUrl).promise;
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
return pdf.numPages;
|
||||
}
|
||||
|
||||
function attachMoveButtons() {
|
||||
var moveUpButtons = document.querySelectorAll(".move-up");
|
||||
for (var i = 0; i < moveUpButtons.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user