From 80604517137406eb7cae316f933c0c46d5d61a7f Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:16:59 +0000 Subject: [PATCH 1/2] Update AutoSplitPdfController.java --- .../controller/api/misc/AutoSplitPdfController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index b793fc3e..cf9b6220 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -43,6 +43,7 @@ import stirling.software.SPDF.utils.WebResponseUtils; public class AutoSplitPdfController { private static final String QR_CONTENT = "https://github.com/Stirling-Tools/Stirling-PDF"; + private static final String QR_CONTENT_OLD = "https://github.com/Frooodle/Stirling-PDF"; @PostMapping(value = "/auto-split-pdf", consumes = "multipart/form-data") @Operation( @@ -63,12 +64,14 @@ public class AutoSplitPdfController { for (int page = 0; page < document.getNumberOfPages(); ++page) { BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 150); String result = decodeQRCode(bim); - - if (QR_CONTENT.equals(result) && page != 0) { + System.out.println("result = " + result); + if ((QR_CONTENT.equals(result) || QR_CONTENT_OLD.equals(result)) && page != 0) { + System.out.println("page " + (page + 1) + " is QR"); splitDocuments.add(new PDDocument()); } - if (!splitDocuments.isEmpty() && !QR_CONTENT.equals(result)) { + if (!splitDocuments.isEmpty() && !QR_CONTENT.equals(result) && !QR_CONTENT_OLD.equals(result)) { + System.out.println("page " + (page + 1) + " is NOT QR"); splitDocuments.get(splitDocuments.size() - 1).addPage(document.getPage(page)); } else if (page == 0) { PDDocument firstDocument = new PDDocument(); @@ -77,7 +80,7 @@ public class AutoSplitPdfController { } // If duplexMode is true and current page is a divider, then skip next page - if (duplexMode && QR_CONTENT.equals(result)) { + if (duplexMode && (QR_CONTENT.equals(result) || QR_CONTENT_OLD.equals(result))) { page++; } } From 6acb593411da56a1c05465f0f1cc0e9ec8f19571 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:17:32 +0000 Subject: [PATCH 2/2] Update AutoSplitPdfController.java --- .../SPDF/controller/api/misc/AutoSplitPdfController.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index cf9b6220..4ca45762 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -64,14 +64,11 @@ public class AutoSplitPdfController { for (int page = 0; page < document.getNumberOfPages(); ++page) { BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 150); String result = decodeQRCode(bim); - System.out.println("result = " + result); if ((QR_CONTENT.equals(result) || QR_CONTENT_OLD.equals(result)) && page != 0) { - System.out.println("page " + (page + 1) + " is QR"); splitDocuments.add(new PDDocument()); } if (!splitDocuments.isEmpty() && !QR_CONTENT.equals(result) && !QR_CONTENT_OLD.equals(result)) { - System.out.println("page " + (page + 1) + " is NOT QR"); splitDocuments.get(splitDocuments.size() - 1).addPage(document.getPage(page)); } else if (page == 0) { PDDocument firstDocument = new PDDocument();