Merge pull request #749 from Stirling-Tools/Frooodle-patch-1
Auto split fix
This commit is contained in:
commit
705c75e51d
1 changed files with 4 additions and 4 deletions
|
@ -43,6 +43,7 @@ import stirling.software.SPDF.utils.WebResponseUtils;
|
||||||
public class AutoSplitPdfController {
|
public class AutoSplitPdfController {
|
||||||
|
|
||||||
private static final String QR_CONTENT = "https://github.com/Stirling-Tools/Stirling-PDF";
|
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")
|
@PostMapping(value = "/auto-split-pdf", consumes = "multipart/form-data")
|
||||||
@Operation(
|
@Operation(
|
||||||
|
@ -63,12 +64,11 @@ public class AutoSplitPdfController {
|
||||||
for (int page = 0; page < document.getNumberOfPages(); ++page) {
|
for (int page = 0; page < document.getNumberOfPages(); ++page) {
|
||||||
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 150);
|
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 150);
|
||||||
String result = decodeQRCode(bim);
|
String result = decodeQRCode(bim);
|
||||||
|
if ((QR_CONTENT.equals(result) || QR_CONTENT_OLD.equals(result)) && page != 0) {
|
||||||
if (QR_CONTENT.equals(result) && page != 0) {
|
|
||||||
splitDocuments.add(new PDDocument());
|
splitDocuments.add(new PDDocument());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!splitDocuments.isEmpty() && !QR_CONTENT.equals(result)) {
|
if (!splitDocuments.isEmpty() && !QR_CONTENT.equals(result) && !QR_CONTENT_OLD.equals(result)) {
|
||||||
splitDocuments.get(splitDocuments.size() - 1).addPage(document.getPage(page));
|
splitDocuments.get(splitDocuments.size() - 1).addPage(document.getPage(page));
|
||||||
} else if (page == 0) {
|
} else if (page == 0) {
|
||||||
PDDocument firstDocument = new PDDocument();
|
PDDocument firstDocument = new PDDocument();
|
||||||
|
@ -77,7 +77,7 @@ public class AutoSplitPdfController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If duplexMode is true and current page is a divider, then skip next page
|
// 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++;
|
page++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue