Changes to splitPDF() function
This commit is contained in:
@@ -245,19 +245,25 @@ async function splitPDF(numRows, inputFile, tempFiles) {
|
||||
// if there are duplicates (back to back duplicates), I only have to print one copy
|
||||
if (pagesNumber > numRows) { // comparison between the number of pages of the pdf file and those of the excel file
|
||||
let displayNumPage = 1;
|
||||
let i;
|
||||
for (i = 1; i < pagesNumber && displayNumPage <= numRows; i += 2) {
|
||||
if (result.pages[i].text.trim() === result.pages[i - 1].text.trim()) {
|
||||
continue;
|
||||
}
|
||||
let lastPrintedText = null;
|
||||
|
||||
for (let i = 0; i < pagesNumber; i++) {
|
||||
let pageText = result.pages[i].text.trim();
|
||||
|
||||
// Only print if the current page is different from the immediate previous page
|
||||
if (pageText !== lastPrintedText) {
|
||||
/*console.log(`--- PAGE ${displayNumPage} ---`);
|
||||
console.log(result.pages[i].text);
|
||||
console.log(pageText);
|
||||
console.log("\n");*/
|
||||
|
||||
// Remember this text for the next iteration
|
||||
lastPrintedText = pageText;
|
||||
|
||||
await processPage(srcPdf, i, tempFiles);
|
||||
displayNumPage++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < pagesNumber; i++) {
|
||||
|
||||
Reference in New Issue
Block a user