dummy lang changes
This commit is contained in:
parent
b8fa278173
commit
4f851156b7
19 changed files with 585 additions and 173 deletions
|
@ -35,10 +35,12 @@ import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo;
|
||||||
import com.itextpdf.kernel.pdf.canvas.parser.listener.IEventListener;
|
import com.itextpdf.kernel.pdf.canvas.parser.listener.IEventListener;
|
||||||
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
|
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import stirling.software.SPDF.utils.WebResponseUtils;
|
import stirling.software.SPDF.utils.WebResponseUtils;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ScalePagesController {
|
public class ScalePagesController {
|
||||||
|
|
||||||
|
@ -47,48 +49,51 @@ public class ScalePagesController {
|
||||||
@PostMapping(value = "/scale-pages", consumes = "multipart/form-data")
|
@PostMapping(value = "/scale-pages", consumes = "multipart/form-data")
|
||||||
@Operation(summary = "Change the size of a PDF page/document", description = "This operation takes an input PDF file and the size to scale the pages to in the output PDF file.")
|
@Operation(summary = "Change the size of a PDF page/document", description = "This operation takes an input PDF file and the size to scale the pages to in the output PDF file.")
|
||||||
public ResponseEntity<byte[]> scalePages(
|
public ResponseEntity<byte[]> scalePages(
|
||||||
@Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file,
|
@Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file,
|
||||||
@Parameter(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", required = true, schema = @Schema(type = "String", allowableValues = { "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "LETTER", "TABLOID", "LEDGER", "LEGAL", "EXECUTIVE" })) @RequestParam("pageSize") String targetPageSize,
|
@Parameter(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", required = true, schema = @Schema(type = "String", allowableValues = {
|
||||||
@Parameter(description = "The scale of the content on the pages of the output PDF. Acceptable values are floats.", required = true, schema = @Schema(type = "float")) @RequestParam("scaleFactor") float scaleFactor)
|
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4",
|
||||||
throws IOException {
|
"B5", "B6", "B7", "B8", "B9", "LETTER", "TABLOID", "LEDGER", "LEGAL",
|
||||||
|
"EXECUTIVE" })) @RequestParam("pageSize") String targetPageSize,
|
||||||
|
@Parameter(description = "The scale of the content on the pages of the output PDF. Acceptable values are floats.", required = true, schema = @Schema(type = "float")) @RequestParam("scaleFactor") float scaleFactor)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
Map<String, PageSize> sizeMap = new HashMap<>();
|
Map<String, PageSize> sizeMap = new HashMap<>();
|
||||||
// Add A0 - A10
|
// Add A0 - A10
|
||||||
sizeMap.put("A0", PageSize.A0);
|
sizeMap.put("A0", PageSize.A0);
|
||||||
sizeMap.put("A1", PageSize.A1);
|
sizeMap.put("A1", PageSize.A1);
|
||||||
sizeMap.put("A2", PageSize.A2);
|
sizeMap.put("A2", PageSize.A2);
|
||||||
sizeMap.put("A3", PageSize.A3);
|
sizeMap.put("A3", PageSize.A3);
|
||||||
sizeMap.put("A4", PageSize.A4);
|
sizeMap.put("A4", PageSize.A4);
|
||||||
sizeMap.put("A5", PageSize.A5);
|
sizeMap.put("A5", PageSize.A5);
|
||||||
sizeMap.put("A6", PageSize.A6);
|
sizeMap.put("A6", PageSize.A6);
|
||||||
sizeMap.put("A7", PageSize.A7);
|
sizeMap.put("A7", PageSize.A7);
|
||||||
sizeMap.put("A8", PageSize.A8);
|
sizeMap.put("A8", PageSize.A8);
|
||||||
sizeMap.put("A9", PageSize.A9);
|
sizeMap.put("A9", PageSize.A9);
|
||||||
sizeMap.put("A10", PageSize.A10);
|
sizeMap.put("A10", PageSize.A10);
|
||||||
// Add B0 - B9
|
// Add B0 - B9
|
||||||
sizeMap.put("B0", PageSize.B0);
|
sizeMap.put("B0", PageSize.B0);
|
||||||
sizeMap.put("B1", PageSize.B1);
|
sizeMap.put("B1", PageSize.B1);
|
||||||
sizeMap.put("B2", PageSize.B2);
|
sizeMap.put("B2", PageSize.B2);
|
||||||
sizeMap.put("B3", PageSize.B3);
|
sizeMap.put("B3", PageSize.B3);
|
||||||
sizeMap.put("B4", PageSize.B4);
|
sizeMap.put("B4", PageSize.B4);
|
||||||
sizeMap.put("B5", PageSize.B5);
|
sizeMap.put("B5", PageSize.B5);
|
||||||
sizeMap.put("B6", PageSize.B6);
|
sizeMap.put("B6", PageSize.B6);
|
||||||
sizeMap.put("B7", PageSize.B7);
|
sizeMap.put("B7", PageSize.B7);
|
||||||
sizeMap.put("B8", PageSize.B8);
|
sizeMap.put("B8", PageSize.B8);
|
||||||
sizeMap.put("B9", PageSize.B9);
|
sizeMap.put("B9", PageSize.B9);
|
||||||
// Add other sizes
|
// Add other sizes
|
||||||
sizeMap.put("LETTER", PageSize.LETTER);
|
sizeMap.put("LETTER", PageSize.LETTER);
|
||||||
sizeMap.put("TABLOID", PageSize.TABLOID);
|
sizeMap.put("TABLOID", PageSize.TABLOID);
|
||||||
sizeMap.put("LEDGER", PageSize.LEDGER);
|
sizeMap.put("LEDGER", PageSize.LEDGER);
|
||||||
sizeMap.put("LEGAL", PageSize.LEGAL);
|
sizeMap.put("LEGAL", PageSize.LEGAL);
|
||||||
sizeMap.put("EXECUTIVE", PageSize.EXECUTIVE);
|
sizeMap.put("EXECUTIVE", PageSize.EXECUTIVE);
|
||||||
|
|
||||||
if (!sizeMap.containsKey(targetPageSize)) {
|
if (!sizeMap.containsKey(targetPageSize)) {
|
||||||
throw new IllegalArgumentException("Invalid pageSize. It must be one of the following: A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10");
|
throw new IllegalArgumentException(
|
||||||
}
|
"Invalid pageSize. It must be one of the following: A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10");
|
||||||
|
}
|
||||||
|
|
||||||
PageSize pageSize = sizeMap.get(targetPageSize);
|
PageSize pageSize = sizeMap.get(targetPageSize);
|
||||||
|
|
||||||
|
|
||||||
byte[] bytes = file.getBytes();
|
byte[] bytes = file.getBytes();
|
||||||
PdfReader reader = new PdfReader(new ByteArrayInputStream(bytes));
|
PdfReader reader = new PdfReader(new ByteArrayInputStream(bytes));
|
||||||
|
@ -97,9 +102,7 @@ public class ScalePagesController {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PdfWriter writer = new PdfWriter(baos);
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
PdfDocument outputPdf = new PdfDocument(writer);
|
PdfDocument outputPdf = new PdfDocument(writer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int totalPages = pdfDoc.getNumberOfPages();
|
int totalPages = pdfDoc.getNumberOfPages();
|
||||||
|
|
||||||
for (int i = 1; i <= totalPages; i++) {
|
for (int i = 1; i <= totalPages; i++) {
|
||||||
|
@ -111,7 +114,7 @@ public class ScalePagesController {
|
||||||
float scaleWidth = pageSize.getWidth() / rect.getWidth();
|
float scaleWidth = pageSize.getWidth() / rect.getWidth();
|
||||||
float scaleHeight = pageSize.getHeight() / rect.getHeight();
|
float scaleHeight = pageSize.getHeight() / rect.getHeight();
|
||||||
float scale = Math.min(scaleWidth, scaleHeight) * scaleFactor;
|
float scale = Math.min(scaleWidth, scaleHeight) * scaleFactor;
|
||||||
System.out.println("Scale: " + scale);
|
System.out.println("Scale: " + scale);
|
||||||
|
|
||||||
PdfFormXObject formXObject = pdfDoc.getPage(i).copyAsFormXObject(outputPdf);
|
PdfFormXObject formXObject = pdfDoc.getPage(i).copyAsFormXObject(outputPdf);
|
||||||
float x = (pageSize.getWidth() - rect.getWidth() * scale) / 2; // Center Page
|
float x = (pageSize.getWidth() - rect.getWidth() * scale) / 2; // Center Page
|
||||||
|
@ -128,130 +131,111 @@ public class ScalePagesController {
|
||||||
outputPdf.close();
|
outputPdf.close();
|
||||||
byte[] pdfContent = baos.toByteArray();
|
byte[] pdfContent = baos.toByteArray();
|
||||||
pdfDoc.close();
|
pdfDoc.close();
|
||||||
return WebResponseUtils.bytesToWebResponse(pdfContent, file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_scaled.pdf");
|
return WebResponseUtils.bytesToWebResponse(pdfContent,
|
||||||
|
file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_scaled.pdf");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/auto-crop", consumes = "multipart/form-data")
|
//TODO
|
||||||
public ResponseEntity<byte[]> cropPdf(@RequestParam("fileInput") MultipartFile file) throws IOException {
|
@Hidden
|
||||||
byte[] bytes = file.getBytes();
|
@PostMapping(value = "/auto-crop", consumes = "multipart/form-data")
|
||||||
PdfReader reader = new PdfReader(new ByteArrayInputStream(bytes));
|
public ResponseEntity<byte[]> cropPdf(@RequestParam("fileInput") MultipartFile file) throws IOException {
|
||||||
PdfDocument pdfDoc = new PdfDocument(reader);
|
byte[] bytes = file.getBytes();
|
||||||
|
PdfReader reader = new PdfReader(new ByteArrayInputStream(bytes));
|
||||||
|
PdfDocument pdfDoc = new PdfDocument(reader);
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PdfWriter writer = new PdfWriter(baos);
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
PdfDocument outputPdf = new PdfDocument(writer);
|
PdfDocument outputPdf = new PdfDocument(writer);
|
||||||
|
|
||||||
int totalPages = pdfDoc.getNumberOfPages();
|
|
||||||
for (int i = 1; i <= totalPages; i++) {
|
|
||||||
PdfPage page = pdfDoc.getPage(i);
|
|
||||||
Rectangle originalMediaBox = page.getMediaBox();
|
|
||||||
|
|
||||||
Rectangle contentBox = determineContentBox(page);
|
|
||||||
|
|
||||||
// Make sure we don't go outside the original media box.
|
|
||||||
Rectangle intersection = originalMediaBox.getIntersection(contentBox);
|
|
||||||
page.setCropBox(intersection);
|
|
||||||
|
|
||||||
// Copy page to the new document
|
int totalPages = pdfDoc.getNumberOfPages();
|
||||||
outputPdf.addPage(page.copyTo(outputPdf));
|
for (int i = 1; i <= totalPages; i++) {
|
||||||
}
|
PdfPage page = pdfDoc.getPage(i);
|
||||||
|
Rectangle originalMediaBox = page.getMediaBox();
|
||||||
|
|
||||||
|
Rectangle contentBox = determineContentBox(page);
|
||||||
|
|
||||||
|
// Make sure we don't go outside the original media box.
|
||||||
|
Rectangle intersection = originalMediaBox.getIntersection(contentBox);
|
||||||
|
page.setCropBox(intersection);
|
||||||
|
|
||||||
|
// Copy page to the new document
|
||||||
|
outputPdf.addPage(page.copyTo(outputPdf));
|
||||||
|
}
|
||||||
|
|
||||||
|
outputPdf.close();
|
||||||
|
byte[] pdfContent = baos.toByteArray();
|
||||||
|
pdfDoc.close();
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""
|
||||||
|
+ file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_cropped.pdf\"")
|
||||||
|
.contentType(MediaType.APPLICATION_PDF).body(pdfContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Rectangle determineContentBox(PdfPage page) {
|
||||||
|
// Extract the text from the page and find the bounding box.
|
||||||
|
TextBoundingRectangleFinder finder = new TextBoundingRectangleFinder();
|
||||||
|
PdfCanvasProcessor processor = new PdfCanvasProcessor(finder);
|
||||||
|
processor.processPageContent(page);
|
||||||
|
return finder.getBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TextBoundingRectangleFinder implements IEventListener {
|
||||||
|
private List<Rectangle> allTextBoxes = new ArrayList<>();
|
||||||
|
|
||||||
|
public Rectangle getBoundingBox() {
|
||||||
|
// Sort the text boxes based on their vertical position
|
||||||
|
allTextBoxes.sort(Comparator.comparingDouble(Rectangle::getTop));
|
||||||
|
|
||||||
|
// Consider a box an outlier if its top is more than 1.5 times the IQR above the
|
||||||
|
// third quartile.
|
||||||
|
int q1Index = allTextBoxes.size() / 4;
|
||||||
|
int q3Index = 3 * allTextBoxes.size() / 4;
|
||||||
|
double iqr = allTextBoxes.get(q3Index).getTop() - allTextBoxes.get(q1Index).getTop();
|
||||||
|
double threshold = allTextBoxes.get(q3Index).getTop() + 1.5 * iqr;
|
||||||
|
|
||||||
|
// Initialize boundingBox to the first non-outlier box
|
||||||
|
int i = 0;
|
||||||
|
while (i < allTextBoxes.size() && allTextBoxes.get(i).getTop() > threshold) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (i == allTextBoxes.size()) {
|
||||||
|
// If all boxes are outliers, just return the first one
|
||||||
|
return allTextBoxes.get(0);
|
||||||
|
}
|
||||||
|
Rectangle boundingBox = allTextBoxes.get(i);
|
||||||
|
|
||||||
|
// Extend the bounding box to include all non-outlier boxes
|
||||||
|
for (; i < allTextBoxes.size(); i++) {
|
||||||
|
Rectangle textBoundingBox = allTextBoxes.get(i);
|
||||||
|
if (textBoundingBox.getTop() > threshold) {
|
||||||
|
// This box is an outlier, skip it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float left = Math.min(boundingBox.getLeft(), textBoundingBox.getLeft());
|
||||||
|
float bottom = Math.min(boundingBox.getBottom(), textBoundingBox.getBottom());
|
||||||
|
float right = Math.max(boundingBox.getRight(), textBoundingBox.getRight());
|
||||||
|
float top = Math.max(boundingBox.getTop(), textBoundingBox.getTop());
|
||||||
|
|
||||||
|
// Add a small padding around the bounding box
|
||||||
|
float padding = 10;
|
||||||
|
boundingBox = new Rectangle(left - padding, bottom - padding, right - left + 2 * padding,
|
||||||
|
top - bottom + 2 * padding);
|
||||||
|
}
|
||||||
|
return boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(IEventData data, EventType type) {
|
||||||
|
if (type == EventType.RENDER_TEXT) {
|
||||||
|
TextRenderInfo renderInfo = (TextRenderInfo) data;
|
||||||
|
allTextBoxes.add(renderInfo.getBaseline().getBoundingRectangle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<EventType> getSupportedEvents() {
|
||||||
|
return Collections.singleton(EventType.RENDER_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
outputPdf.close();
|
|
||||||
byte[] pdfContent = baos.toByteArray();
|
|
||||||
pdfDoc.close();
|
|
||||||
return ResponseEntity.ok()
|
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_cropped.pdf\"")
|
|
||||||
.contentType(MediaType.APPLICATION_PDF)
|
|
||||||
.body(pdfContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rectangle determineContentBox(PdfPage page) {
|
|
||||||
// Extract the text from the page and find the bounding box.
|
|
||||||
TextBoundingRectangleFinder finder = new TextBoundingRectangleFinder();
|
|
||||||
PdfCanvasProcessor processor = new PdfCanvasProcessor(finder);
|
|
||||||
processor.processPageContent(page);
|
|
||||||
return finder.getBoundingBox();
|
|
||||||
}
|
|
||||||
private static class TextBoundingRectangleFinder implements IEventListener {
|
|
||||||
private List<Rectangle> allTextBoxes = new ArrayList<>();
|
|
||||||
|
|
||||||
public Rectangle getBoundingBox() {
|
|
||||||
// Sort the text boxes based on their vertical position
|
|
||||||
allTextBoxes.sort(Comparator.comparingDouble(Rectangle::getTop));
|
|
||||||
|
|
||||||
// Consider a box an outlier if its top is more than 1.5 times the IQR above the third quartile.
|
|
||||||
int q1Index = allTextBoxes.size() / 4;
|
|
||||||
int q3Index = 3 * allTextBoxes.size() / 4;
|
|
||||||
double iqr = allTextBoxes.get(q3Index).getTop() - allTextBoxes.get(q1Index).getTop();
|
|
||||||
double threshold = allTextBoxes.get(q3Index).getTop() + 1.5 * iqr;
|
|
||||||
|
|
||||||
// Initialize boundingBox to the first non-outlier box
|
|
||||||
int i = 0;
|
|
||||||
while (i < allTextBoxes.size() && allTextBoxes.get(i).getTop() > threshold) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (i == allTextBoxes.size()) {
|
|
||||||
// If all boxes are outliers, just return the first one
|
|
||||||
return allTextBoxes.get(0);
|
|
||||||
}
|
|
||||||
Rectangle boundingBox = allTextBoxes.get(i);
|
|
||||||
|
|
||||||
// Extend the bounding box to include all non-outlier boxes
|
|
||||||
for (; i < allTextBoxes.size(); i++) {
|
|
||||||
Rectangle textBoundingBox = allTextBoxes.get(i);
|
|
||||||
if (textBoundingBox.getTop() > threshold) {
|
|
||||||
// This box is an outlier, skip it
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
float left = Math.min(boundingBox.getLeft(), textBoundingBox.getLeft());
|
|
||||||
float bottom = Math.min(boundingBox.getBottom(), textBoundingBox.getBottom());
|
|
||||||
float right = Math.max(boundingBox.getRight(), textBoundingBox.getRight());
|
|
||||||
float top = Math.max(boundingBox.getTop(), textBoundingBox.getTop());
|
|
||||||
|
|
||||||
// Add a small padding around the bounding box
|
|
||||||
float padding = 10;
|
|
||||||
boundingBox = new Rectangle(left - padding, bottom - padding, right - left + 2 * padding, top - bottom + 2 * padding);
|
|
||||||
}
|
|
||||||
return boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void eventOccurred(IEventData data, EventType type) {
|
|
||||||
if (type == EventType.RENDER_TEXT) {
|
|
||||||
TextRenderInfo renderInfo = (TextRenderInfo) data;
|
|
||||||
allTextBoxes.add(renderInfo.getBaseline().getBoundingRectangle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<EventType> getSupportedEvents() {
|
|
||||||
return Collections.singleton(EventType.RENDER_TEXT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
package stirling.software.SPDF.controller.api.other;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import com.itextpdf.io.source.ByteArrayOutputStream;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import stirling.software.SPDF.utils.ProcessExecutor;
|
||||||
|
import stirling.software.SPDF.utils.WebResponseUtils;
|
||||||
|
//Required for PDF manipulation
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDPage;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||||
|
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||||
|
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
||||||
|
import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
|
||||||
|
import org.apache.pdfbox.rendering.ImageType;
|
||||||
|
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||||
|
|
||||||
|
|
||||||
|
//Required for image manipulation
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.BufferedImageOp;
|
||||||
|
import java.awt.image.RescaleOp;
|
||||||
|
import java.awt.image.AffineTransformOp;
|
||||||
|
import java.awt.image.ConvolveOp;
|
||||||
|
import java.awt.image.Kernel;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
|
//Required for image input/output
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
//Required for file input/output
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
//Other required classes
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class FakeScanController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FakeScanController.class);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
@Hidden
|
||||||
|
@PostMapping(consumes = "multipart/form-data", value = "/fakeScan")
|
||||||
|
@Operation(
|
||||||
|
summary = "Repair a PDF file",
|
||||||
|
description = "This endpoint repairs a given PDF file by running Ghostscript command. The PDF is first saved to a temporary location, repaired, read back, and then returned as a response."
|
||||||
|
)
|
||||||
|
public ResponseEntity<byte[]> repairPdf(
|
||||||
|
@RequestPart(required = true, value = "fileInput")
|
||||||
|
@Parameter(description = "The input PDF file to be repaired", required = true)
|
||||||
|
MultipartFile inputFile) throws IOException, InterruptedException {
|
||||||
|
|
||||||
|
PDDocument document = PDDocument.load(inputFile.getBytes());
|
||||||
|
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
||||||
|
for (int page = 0; page < document.getNumberOfPages(); ++page)
|
||||||
|
{
|
||||||
|
BufferedImage image = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
|
||||||
|
ImageIO.write(image, "png", new File("scanned-" + (page+1) + ".png"));
|
||||||
|
}
|
||||||
|
document.close();
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
int scannedness = 90; // Value between 0 and 100
|
||||||
|
int dirtiness = 0; // Value between 0 and 100
|
||||||
|
|
||||||
|
// Load the source image
|
||||||
|
BufferedImage sourceImage = ImageIO.read(new File("scanned-1.png"));
|
||||||
|
|
||||||
|
// Create the destination image
|
||||||
|
BufferedImage destinationImage = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), sourceImage.getType());
|
||||||
|
|
||||||
|
// Apply a brightness and contrast effect based on the "scanned-ness"
|
||||||
|
float scaleFactor = 1.0f + (scannedness / 100.0f) * 0.5f; // Between 1.0 and 1.5
|
||||||
|
float offset = scannedness * 1.5f; // Between 0 and 150
|
||||||
|
BufferedImageOp op = new RescaleOp(scaleFactor, offset, null);
|
||||||
|
op.filter(sourceImage, destinationImage);
|
||||||
|
|
||||||
|
// Apply a rotation effect
|
||||||
|
double rotationRequired = Math.toRadians((new Random().nextInt(3 - 1) + 1)); // Random angle between 1 and 3 degrees
|
||||||
|
double locationX = destinationImage.getWidth() / 2;
|
||||||
|
double locationY = destinationImage.getHeight() / 2;
|
||||||
|
AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY);
|
||||||
|
AffineTransformOp rotateOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
|
||||||
|
destinationImage = rotateOp.filter(destinationImage, null);
|
||||||
|
|
||||||
|
// Apply a blur effect based on the "scanned-ness"
|
||||||
|
float blurIntensity = scannedness / 100.0f * 0.2f; // Between 0.0 and 0.2
|
||||||
|
float[] matrix = {
|
||||||
|
blurIntensity, blurIntensity, blurIntensity,
|
||||||
|
blurIntensity, blurIntensity, blurIntensity,
|
||||||
|
blurIntensity, blurIntensity, blurIntensity
|
||||||
|
};
|
||||||
|
BufferedImageOp blurOp = new ConvolveOp(new Kernel(3, 3, matrix), ConvolveOp.EDGE_NO_OP, null);
|
||||||
|
destinationImage = blurOp.filter(destinationImage, null);
|
||||||
|
|
||||||
|
// Add noise to the image based on the "dirtiness"
|
||||||
|
Random random = new Random();
|
||||||
|
for (int y = 0; y < destinationImage.getHeight(); y++) {
|
||||||
|
for (int x = 0; x < destinationImage.getWidth(); x++) {
|
||||||
|
if (random.nextInt(100) < dirtiness) {
|
||||||
|
// Change the pixel color to black randomly based on the "dirtiness"
|
||||||
|
destinationImage.setRGB(x, y, Color.BLACK.getRGB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the image
|
||||||
|
ImageIO.write(destinationImage, "PNG", new File("scanned-1.png"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PDDocument documentOut = new PDDocument();
|
||||||
|
for (int page = 1; page <= document.getNumberOfPages(); ++page)
|
||||||
|
{
|
||||||
|
BufferedImage bim = ImageIO.read(new File("scanned-" + page + ".png"));
|
||||||
|
|
||||||
|
// Adjust the dimensions of the page
|
||||||
|
PDPage pdPage = new PDPage(new PDRectangle(bim.getWidth() - 1, bim.getHeight() - 1));
|
||||||
|
documentOut.addPage(pdPage);
|
||||||
|
|
||||||
|
PDImageXObject pdImage = LosslessFactory.createFromImage(documentOut, bim);
|
||||||
|
PDPageContentStream contentStream = new PDPageContentStream(documentOut, pdPage);
|
||||||
|
|
||||||
|
// Draw the image with a slight offset and enlarged dimensions
|
||||||
|
contentStream.drawImage(pdImage, -1, -1, bim.getWidth() + 2, bim.getHeight() + 2);
|
||||||
|
contentStream.close();
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
documentOut.save(baos);
|
||||||
|
documentOut.close();
|
||||||
|
|
||||||
|
// Return the optimized PDF as a response
|
||||||
|
String outputFilename = inputFile.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_scanned.pdf";
|
||||||
|
return WebResponseUtils.boasToWebResponse(baos, outputFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -132,12 +132,31 @@ home.removeBlanks.desc = يكتشف ويزيل الصفحات الفارغة م
|
||||||
home.compare.title = قارن
|
home.compare.title = قارن
|
||||||
home.compare.desc = يقارن ويظهر الاختلافات بين 2 من مستندات PDF
|
home.compare.desc = يقارن ويظهر الاختلافات بين 2 من مستندات PDF
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf = تنزيل PDF
|
downloadPdf = تنزيل PDF
|
||||||
text=نص
|
text=نص
|
||||||
font=الخط
|
font=الخط
|
||||||
selectFillter = - حدد -
|
selectFillter = - حدد -
|
||||||
pageNum = رقم الصفحة
|
pageNum = رقم الصفحة
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title = توقيع الشهادة
|
certSign.title = توقيع الشهادة
|
||||||
certSign.header = قم بتوقيع ملف PDF بشهادتك (العمل قيد التقدم)
|
certSign.header = قم بتوقيع ملف PDF بشهادتك (العمل قيد التقدم)
|
||||||
certSign.selectPDF = حدد ملف PDF للتوقيع:
|
certSign.selectPDF = حدد ملف PDF للتوقيع:
|
||||||
|
@ -339,6 +358,9 @@ addPassword.selectText.10=منع التعديل
|
||||||
addPassword.selectText.11=منع تعديل التعليقات التوضيحية
|
addPassword.selectText.11=منع تعديل التعليقات التوضيحية
|
||||||
addPassword.selectText.12=منع الطباعة
|
addPassword.selectText.12=منع الطباعة
|
||||||
addPassword.selectText.13=منع طباعة تنسيقات مختلفة
|
addPassword.selectText.13=منع طباعة تنسيقات مختلفة
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=تشفير
|
addPassword.submit=تشفير
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -125,12 +125,31 @@ home.removeBlanks.desc=Detecta i elimina les pàgines en blanc d'un document
|
||||||
home.compare.title=Compara
|
home.compare.title=Compara
|
||||||
home.compare.desc=Compara i mostra les diferències entre 2 documents PDF
|
home.compare.desc=Compara i mostra les diferències entre 2 documents PDF
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Descarregueu PDF
|
downloadPdf=Descarregueu PDF
|
||||||
text=Text
|
text=Text
|
||||||
font=Tipus de lletra
|
font=Tipus de lletra
|
||||||
selectFillter=-- Selecciona --
|
selectFillter=-- Selecciona --
|
||||||
pageNum=Número de pàgina
|
pageNum=Número de pàgina
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Significació del certificat
|
certSign.title=Significació del certificat
|
||||||
certSign.header=Firmar un PDF amb el vostre certificat (Treball en curs)
|
certSign.header=Firmar un PDF amb el vostre certificat (Treball en curs)
|
||||||
certSign.selectPDF=Seleccioneu un fitxer PDF per signar:
|
certSign.selectPDF=Seleccioneu un fitxer PDF per signar:
|
||||||
|
@ -337,6 +356,9 @@ addPassword.selectText.10=Evita modificacions
|
||||||
addPassword.selectText.11=Evita modificacions d'annotacions
|
addPassword.selectText.11=Evita modificacions d'annotacions
|
||||||
addPassword.selectText.12=Evita impressió
|
addPassword.selectText.12=Evita impressió
|
||||||
addPassword.selectText.13=Evita impressió de diferents formats
|
addPassword.selectText.13=Evita impressió de diferents formats
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Encripta
|
addPassword.submit=Encripta
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -124,12 +124,31 @@ home.removeBlanks.desc=Erkennt und entfernt leere Seiten aus einem Dokument
|
||||||
home.compare.title=Vergleichen
|
home.compare.title=Vergleichen
|
||||||
home.compare.desc=Vergleicht und zeigt die Unterschiede zwischen zwei PDF-Dokumenten an
|
home.compare.desc=Vergleicht und zeigt die Unterschiede zwischen zwei PDF-Dokumenten an
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=PDF herunterladen
|
downloadPdf=PDF herunterladen
|
||||||
text=Text
|
text=Text
|
||||||
font=Schriftart
|
font=Schriftart
|
||||||
selectFillter=-- Auswählen --
|
selectFillter=-- Auswählen --
|
||||||
pageNum=Seitenzahl
|
pageNum=Seitenzahl
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Zertifikatsignierung
|
certSign.title=Zertifikatsignierung
|
||||||
certSign.header=Signieren Sie ein PDF mit Ihrem Zertifikat (in Arbeit)
|
certSign.header=Signieren Sie ein PDF mit Ihrem Zertifikat (in Arbeit)
|
||||||
certSign.selectPDF=Wählen Sie eine PDF-Datei zum Signieren aus:
|
certSign.selectPDF=Wählen Sie eine PDF-Datei zum Signieren aus:
|
||||||
|
@ -334,6 +353,9 @@ addPassword.selectText.10=Modifizierung verhindern
|
||||||
addPassword.selectText.11=Ändern von Kommentaren verhindern
|
addPassword.selectText.11=Ändern von Kommentaren verhindern
|
||||||
addPassword.selectText.12=Drucken verhindern
|
addPassword.selectText.12=Drucken verhindern
|
||||||
addPassword.selectText.13=Drucken verschiedener Formate verhindern
|
addPassword.selectText.13=Drucken verschiedener Formate verhindern
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Verschlüsseln
|
addPassword.submit=Verschlüsseln
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -129,7 +129,7 @@ home.pageLayout.title=Multi-Page Layout
|
||||||
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
home.scalePages.title=Adjust page size/scale
|
home.scalePages.title=Adjust page size/scale
|
||||||
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
home.scalePages.desc=Change the size/scale of a page and/or its contents.
|
||||||
|
|
||||||
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
|
|
|
@ -124,12 +124,31 @@ home.removeBlanks.descdetecta y elimina páginas en blanco de un documento
|
||||||
home.compare.title=Comparar
|
home.compare.title=Comparar
|
||||||
home.compare.desc=Compara y muestra las diferencias entre 2 documentos PDF
|
home.compare.desc=Compara y muestra las diferencias entre 2 documentos PDF
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Descargar PDF
|
downloadPdf=Descargar PDF
|
||||||
text=Texto
|
text=Texto
|
||||||
font=Fuente
|
font=Fuente
|
||||||
selectFilter=-- Seleccionar --
|
selectFilter=-- Seleccionar --
|
||||||
pageNum=Número de página
|
pageNum=Número de página
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Firma de certificado
|
certSign.title=Firma de certificado
|
||||||
certSign.header=Firme un PDF con su certificado (Trabajo en progreso)
|
certSign.header=Firme un PDF con su certificado (Trabajo en progreso)
|
||||||
certSign.selectPDF=Seleccione un archivo PDF para firmar:
|
certSign.selectPDF=Seleccione un archivo PDF para firmar:
|
||||||
|
@ -335,6 +354,9 @@ addPassword.selectText.10=Impedir modificación
|
||||||
addPassword.selectText.11=Impedir modificación de anotaciones
|
addPassword.selectText.11=Impedir modificación de anotaciones
|
||||||
addPassword.selectText.12=Impedir imprimir
|
addPassword.selectText.12=Impedir imprimir
|
||||||
addPassword.selectText.13=Impedir imprimir diferentes formatos
|
addPassword.selectText.13=Impedir imprimir diferentes formatos
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Encriptar
|
addPassword.submit=Encriptar
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -130,12 +130,31 @@ home.removeBlanks.desc=Détecte et supprime les pages vierges d'un document
|
||||||
home.compare.title=Comparer
|
home.compare.title=Comparer
|
||||||
home.compare.desc=Compare et affiche les différences entre 2 documents PDF
|
home.compare.desc=Compare et affiche les différences entre 2 documents PDF
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Télécharger le PDF
|
downloadPdf=Télécharger le PDF
|
||||||
text=Texte
|
text=Texte
|
||||||
font=Police
|
font=Police
|
||||||
selectFilter=-- Sélectionner --
|
selectFilter=-- Sélectionner --
|
||||||
pageNum=numéro de page
|
pageNum=numéro de page
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Signature du certificat
|
certSign.title=Signature du certificat
|
||||||
certSign.header=Signer un PDF avec votre certificat (Travail en cours)
|
certSign.header=Signer un PDF avec votre certificat (Travail en cours)
|
||||||
certSign.selectPDF=Sélectionnez un fichier PDF à signer :
|
certSign.selectPDF=Sélectionnez un fichier PDF à signer :
|
||||||
|
@ -334,6 +353,9 @@ addPassword.selectText.10=Empêcher la modification
|
||||||
addPassword.selectText.11=Empêcher la modification des annotations
|
addPassword.selectText.11=Empêcher la modification des annotations
|
||||||
addPassword.selectText.12=Empêcher l'impression
|
addPassword.selectText.12=Empêcher l'impression
|
||||||
addPassword.selectText.13=Empêcher l'impression de différents formats
|
addPassword.selectText.13=Empêcher l'impression de différents formats
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Crypter
|
addPassword.submit=Crypter
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -125,12 +125,31 @@ home.removeBlanks.desc=Trova e rimuovi pagine vuote da un PDF.
|
||||||
home.compare.title=Compara
|
home.compare.title=Compara
|
||||||
home.compare.desc=Vedi e compara le differenze tra due PDF.
|
home.compare.desc=Vedi e compara le differenze tra due PDF.
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Scarica PDF
|
downloadPdf=Scarica PDF
|
||||||
text=Testo
|
text=Testo
|
||||||
font=Font
|
font=Font
|
||||||
selectFillter=-- Seleziona --
|
selectFillter=-- Seleziona --
|
||||||
pageNum=Numero pagina
|
pageNum=Numero pagina
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Firma del certificato
|
certSign.title=Firma del certificato
|
||||||
certSign.header=Firma un PDF con il tuo certificato (Lavoro in corso)
|
certSign.header=Firma un PDF con il tuo certificato (Lavoro in corso)
|
||||||
certSign.selectPDF=Seleziona un file PDF per la firma:
|
certSign.selectPDF=Seleziona un file PDF per la firma:
|
||||||
|
@ -337,6 +356,9 @@ addPassword.selectText.10=Previeni modifiche
|
||||||
addPassword.selectText.11=Previeni annotazioni
|
addPassword.selectText.11=Previeni annotazioni
|
||||||
addPassword.selectText.12=Previeni stampa
|
addPassword.selectText.12=Previeni stampa
|
||||||
addPassword.selectText.13=Previeni stampa in diversi formati
|
addPassword.selectText.13=Previeni stampa in diversi formati
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Crittografa
|
addPassword.submit=Crittografa
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -128,6 +128,13 @@ home.compare.desc=2개의 PDF 문서를 비교하고 차이를 표시합니다.
|
||||||
home.certSign.title=인증서로 서명
|
home.certSign.title=인증서로 서명
|
||||||
home.certSign.desc=PDF에 인증서/키로 서명합니다. (PEM/P12)
|
home.certSign.desc=PDF에 인증서/키로 서명합니다. (PEM/P12)
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=PDF 다운로드
|
downloadPdf=PDF 다운로드
|
||||||
text=텍스트
|
text=텍스트
|
||||||
|
@ -135,6 +142,17 @@ font=폰트
|
||||||
selectFillter=-- 선택 --
|
selectFillter=-- 선택 --
|
||||||
pageNum=페이지 번호
|
pageNum=페이지 번호
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=인증서로 서명
|
certSign.title=인증서로 서명
|
||||||
certSign.header=PDF에 당신의 인증서로 서명하세요 (개발 중)
|
certSign.header=PDF에 당신의 인증서로 서명하세요 (개발 중)
|
||||||
certSign.selectPDF=서명할 PDF를 선택하세요:
|
certSign.selectPDF=서명할 PDF를 선택하세요:
|
||||||
|
@ -368,7 +386,10 @@ addPassword.selectText.9=양식 작성 방지
|
||||||
addPassword.selectText.10=수정 방지
|
addPassword.selectText.10=수정 방지
|
||||||
addPassword.selectText.11=주석 수정 방지
|
addPassword.selectText.11=주석 수정 방지
|
||||||
addPassword.selectText.12=인쇄 방지
|
addPassword.selectText.12=인쇄 방지
|
||||||
addPassword.selectText.13=다른 형식으로 인쇄 방지
|
addPassword.selectText.13=다른 형ì‹<C3AC>으로 ì<>¸ì‡„ ë°©ì§
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself€
|
||||||
addPassword.submit=암호화
|
addPassword.submit=암호화
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -359,6 +359,9 @@ addPassword.selectText.10=Zablokuj modyfikacje
|
||||||
addPassword.selectText.11=Zablokuj modyfikacje adnotacji
|
addPassword.selectText.11=Zablokuj modyfikacje adnotacji
|
||||||
addPassword.selectText.12=Zablokuj drukowanie
|
addPassword.selectText.12=Zablokuj drukowanie
|
||||||
addPassword.selectText.13=Zablokuj drukowanie różnych formatów
|
addPassword.selectText.13=Zablokuj drukowanie różnych formatów
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Zablokuj
|
addPassword.submit=Zablokuj
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -128,6 +128,13 @@ home.compare.desc=Compara e mostra as diferenças entre 2 documentos PDF
|
||||||
home.certSign.title=Assinar com certificado
|
home.certSign.title=Assinar com certificado
|
||||||
home.certSign.desc=Assina um PDF com um Certificado/Chave (PEM/P12)
|
home.certSign.desc=Assina um PDF com um Certificado/Chave (PEM/P12)
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=baixar PDF
|
downloadPdf=baixar PDF
|
||||||
text=Texto
|
text=Texto
|
||||||
|
@ -135,6 +142,17 @@ font=Fonte
|
||||||
selectFillter=-- Selecione --
|
selectFillter=-- Selecione --
|
||||||
pageNum=Número de página
|
pageNum=Número de página
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Assinatura de certificado
|
certSign.title=Assinatura de certificado
|
||||||
certSign.header=Assine um PDF com seu certificado (Trabalho em andamento)
|
certSign.header=Assine um PDF com seu certificado (Trabalho em andamento)
|
||||||
certSign.selectPDF=Selecione um arquivo PDF para assinatura:
|
certSign.selectPDF=Selecione um arquivo PDF para assinatura:
|
||||||
|
@ -345,6 +363,9 @@ addPassword.selectText.10=Impedir modificação
|
||||||
addPassword.selectText.11=Impedir a modificação da anotação
|
addPassword.selectText.11=Impedir a modificação da anotação
|
||||||
addPassword.selectText.12=Impedir a impressão
|
addPassword.selectText.12=Impedir a impressão
|
||||||
addPassword.selectText.13=Impedir a impressão de formatos diferentes
|
addPassword.selectText.13=Impedir a impressão de formatos diferentes
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=criptografar
|
addPassword.submit=criptografar
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -109,12 +109,31 @@ home.compare.desc=Compară și arată diferențele dintre 2 documente PDF.
|
||||||
home.certSign.title=Semnare cu certificat
|
home.certSign.title=Semnare cu certificat
|
||||||
home.certSign.desc=Semnează un PDF cu un certificat/cheie (PEM/P12)
|
home.certSign.desc=Semnează un PDF cu un certificat/cheie (PEM/P12)
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Descarcă PDF
|
downloadPdf=Descarcă PDF
|
||||||
text=Text
|
text=Text
|
||||||
font=Font
|
font=Font
|
||||||
selectFillter=-- Selectează --
|
selectFillter=-- Selectează --
|
||||||
pageNum=Numărul paginii
|
pageNum=Numărul paginii
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title = Semnare certificat
|
certSign.title = Semnare certificat
|
||||||
certSign.header = Semnează un fișier PDF cu certificatul tău (În curs de desfășurare)
|
certSign.header = Semnează un fișier PDF cu certificatul tău (În curs de desfășurare)
|
||||||
certSign.selectPDF = Selectează un fișier PDF pentru semnare:
|
certSign.selectPDF = Selectează un fișier PDF pentru semnare:
|
||||||
|
@ -316,6 +335,9 @@ addPassword.selectText.10=Preveniți modificarea
|
||||||
addPassword.selectText.11=Preveniți modificarea adnotărilor
|
addPassword.selectText.11=Preveniți modificarea adnotărilor
|
||||||
addPassword.selectText.12=Preveniți tipărirea
|
addPassword.selectText.12=Preveniți tipărirea
|
||||||
addPassword.selectText.13=Preveniți tipărirea în formate diferite
|
addPassword.selectText.13=Preveniți tipărirea în formate diferite
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Criptare
|
addPassword.submit=Criptare
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -125,12 +125,31 @@ home.removeBlanks.desc=Обнаруживает и удаляет пустые
|
||||||
home.compare.title=Сравнение
|
home.compare.title=Сравнение
|
||||||
home.compare.desc=Сравнивает и показывает различия между двумя PDF-документами
|
home.compare.desc=Сравнивает и показывает различия между двумя PDF-документами
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Скачать PDF
|
downloadPdf=Скачать PDF
|
||||||
text=Текст
|
text=Текст
|
||||||
font=Шрифт
|
font=Шрифт
|
||||||
selectFillter=-- Выбрать --
|
selectFillter=-- Выбрать --
|
||||||
pageNum=номер страницы
|
pageNum=номер страницы
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Подписание сертификата
|
certSign.title=Подписание сертификата
|
||||||
certSign.header=Подпишите PDF своим сертификатом (работа в процессе)
|
certSign.header=Подпишите PDF своим сертификатом (работа в процессе)
|
||||||
certSign.selectPDF=Выберите файл PDF для подписи:
|
certSign.selectPDF=Выберите файл PDF для подписи:
|
||||||
|
@ -338,6 +357,9 @@ addPassword.selectText.10=Предотвратить модификацию
|
||||||
addPassword.selectText.11=Запретить модификацию аннотаций
|
addPassword.selectText.11=Запретить модификацию аннотаций
|
||||||
addPassword.selectText.12=Запретить печать
|
addPassword.selectText.12=Запретить печать
|
||||||
addPassword.selectText.13=Запретить печать разных форматов
|
addPassword.selectText.13=Запретить печать разных форматов
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Шифровать
|
addPassword.submit=Шифровать
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -125,12 +125,31 @@ home.removeBlanks.desc=Känner av och tar bort tomma sidor från ett dokument
|
||||||
home.compare.title=Jämför
|
home.compare.title=Jämför
|
||||||
home.compare.desc=Jämför och visar skillnaderna mellan 2 PDF-dokument
|
home.compare.desc=Jämför och visar skillnaderna mellan 2 PDF-dokument
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=Ladda ner PDF
|
downloadPdf=Ladda ner PDF
|
||||||
text=Text
|
text=Text
|
||||||
font=Teckensnitt
|
font=Teckensnitt
|
||||||
selectFillter=-- Välj --
|
selectFillter=-- Välj --
|
||||||
pageNum=Sidnummer
|
pageNum=Sidnummer
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=Certifikatsignering
|
certSign.title=Certifikatsignering
|
||||||
certSign.header=Skriv under en PDF med ditt certifikat (Pågående arbete)
|
certSign.header=Skriv under en PDF med ditt certifikat (Pågående arbete)
|
||||||
certSign.selectPDF=Välj en PDF-fil för signering:
|
certSign.selectPDF=Välj en PDF-fil för signering:
|
||||||
|
@ -338,6 +357,9 @@ addPassword.selectText.10=Förhindra modifiering
|
||||||
addPassword.selectText.11=Förhindra anteckningsändring
|
addPassword.selectText.11=Förhindra anteckningsändring
|
||||||
addPassword.selectText.12=Förhindra utskrift
|
addPassword.selectText.12=Förhindra utskrift
|
||||||
addPassword.selectText.13=Förhindra utskrift av olika format
|
addPassword.selectText.13=Förhindra utskrift av olika format
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself
|
||||||
addPassword.submit=Kryptera
|
addPassword.submit=Kryptera
|
||||||
|
|
||||||
#vattenstämpel
|
#vattenstämpel
|
||||||
|
|
|
@ -125,12 +125,31 @@ home.removeBlanks.desc=\u68C0\u6D4B\u5E76\u5220\u9664\u6587\u6863\u4E2D\u7684\u7
|
||||||
home.compare.title=\u6BD4\u8F83
|
home.compare.title=\u6BD4\u8F83
|
||||||
home.compare.desc=\u6BD4\u8F83\u5E76\u663E\u793A 2 \u4E2A PDF \u6587\u6863\u4E4B\u95F4\u7684\u5DEE\u5F02
|
home.compare.desc=\u6BD4\u8F83\u5E76\u663E\u793A 2 \u4E2A PDF \u6587\u6863\u4E4B\u95F4\u7684\u5DEE\u5F02
|
||||||
|
|
||||||
|
home.pageLayout.title=Multi-Page Layout
|
||||||
|
home.pageLayout.desc=Merge multiple pages of a PDF document into a single page
|
||||||
|
|
||||||
|
home.scalePages.title=Adjust page size/scale
|
||||||
|
home.scalePages.desc=Change the size/scale of page and/or its contents.
|
||||||
|
|
||||||
|
error.pdfPassword=The PDF Document is passworded and either the password was not provided or was incorrect
|
||||||
|
|
||||||
downloadPdf=\u4E0B\u8F7DPDF
|
downloadPdf=\u4E0B\u8F7DPDF
|
||||||
text=\u6587\u672C
|
text=\u6587\u672C
|
||||||
font=\u5B57\u4F53
|
font=\u5B57\u4F53
|
||||||
selectFillter=-- 选择--
|
selectFillter=-- 选择--
|
||||||
pageNum=页码
|
pageNum=页码
|
||||||
|
|
||||||
|
pageLayout.title=Multi Page Layout
|
||||||
|
pageLayout.header=Multi Page Layout
|
||||||
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
scalePages.title=Adjust page-scale
|
||||||
|
scalePages.header=Adjust page-scale
|
||||||
|
scalePages.pageSize=Size of a page of the document.
|
||||||
|
scalePages.scaleFactor=Zoom level (crop) of a page.
|
||||||
|
scalePages.submit=Submit
|
||||||
|
|
||||||
certSign.title=证书签名
|
certSign.title=证书签名
|
||||||
certSign.header=使用您的证书签署 PDF(进行中)
|
certSign.header=使用您的证书签署 PDF(进行中)
|
||||||
certSign.selectPDF=选择要签名的 PDF 文件:
|
certSign.selectPDF=选择要签名的 PDF 文件:
|
||||||
|
@ -336,7 +355,10 @@ addPassword.selectText.9=防止填写表格
|
||||||
addPassword.selectText.10=防止修改
|
addPassword.selectText.10=防止修改
|
||||||
addPassword.selectText.11=防止修改注释
|
addPassword.selectText.11=防止修改注释
|
||||||
addPassword.selectText.12=防止打印
|
addPassword.selectText.12=防止打印
|
||||||
addPassword.selectText.13=防止打印不同的格式
|
addPassword.selectText.13=防æ¢æ‰“å<EFBFBD>°ä¸<EFBFBD>å<EFBFBD>Œçš„æ ¼å¼
|
||||||
|
addPassword.selectText.14=Owner Password
|
||||||
|
addPassword.selectText.15=Restricts what can be done with the document once it is opened (Not supported by all readers)
|
||||||
|
addPassword.selectText.16=Restricts the opening of the document itself<6C>
|
||||||
addPassword.submit=加密
|
addPassword.submit=加密
|
||||||
|
|
||||||
#watermark
|
#watermark
|
||||||
|
|
|
@ -5,11 +5,12 @@ function showErrorBanner(message, stackTrace) {
|
||||||
document.querySelector("#errorContainer p").textContent = message;
|
document.querySelector("#errorContainer p").textContent = message;
|
||||||
document.querySelector("#traceContent").textContent = stackTrace;
|
document.querySelector("#traceContent").textContent = stackTrace;
|
||||||
}
|
}
|
||||||
|
let firstErrorOccurred = false;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('form').submit(async function(event) {
|
$('form').submit(async function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
firstErrorOccurred = false;
|
||||||
const url = this.action;
|
const url = this.action;
|
||||||
const files = $('#fileInput-input')[0].files;
|
const files = $('#fileInput-input')[0].files;
|
||||||
const formData = new FormData(this);
|
const formData = new FormData(this);
|
||||||
|
@ -83,7 +84,10 @@ async function handleJsonResponse(response) {
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
const errorMessage = JSON.stringify(json, null, 2);
|
const errorMessage = JSON.stringify(json, null, 2);
|
||||||
if (errorMessage.toLowerCase().includes('the password is incorrect') || errorMessage.toLowerCase().includes('Password is not provided') || errorMessage.toLowerCase().includes('PDF contains an encryption dictionary')) {
|
if (errorMessage.toLowerCase().includes('the password is incorrect') || errorMessage.toLowerCase().includes('Password is not provided') || errorMessage.toLowerCase().includes('PDF contains an encryption dictionary')) {
|
||||||
alert(pdfPasswordPrompt);
|
if (!firstErrorOccurred) {
|
||||||
|
firstErrorOccurred = true;
|
||||||
|
alert(pdfPasswordPrompt);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorBanner(json.error + ':' + json.message, json.trace);
|
showErrorBanner(json.error + ':' + json.message, json.trace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const fileInput = document.getElementById(elementID);
|
const fileInput = document.getElementById(elementID);
|
||||||
|
|
||||||
// Prevent default behavior for drag events
|
// Prevent default behavior for drag events
|
||||||
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
||||||
fileInput.addEventListener(eventName, preventDefaults, false);
|
fileInput.addEventListener(eventName, preventDefaults, false);
|
||||||
|
@ -22,7 +21,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(elementID).on("change", function() {
|
$("#"+elementID).on("change", function() {
|
||||||
handleFileInputChange(this);
|
handleFileInputChange(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +33,6 @@ function handleFileInputChange(inputElement) {
|
||||||
fileNames.forEach(fileName => {
|
fileNames.forEach(fileName => {
|
||||||
selectedFilesContainer.append("<div>" + fileName + "</div>");
|
selectedFilesContainer.append("<div>" + fileName + "</div>");
|
||||||
});
|
});
|
||||||
console.log("fileNames.length=" + fileNames.length)
|
|
||||||
if (fileNames.length === 1) {
|
if (fileNames.length === 1) {
|
||||||
$(inputElement).siblings(".custom-file-label").addClass("selected").html(fileNames[0]);
|
$(inputElement).siblings(".custom-file-label").addClass("selected").html(fileNames[0]);
|
||||||
} else if (fileNames.length > 1) {
|
} else if (fileNames.length > 1) {
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
|
|
||||||
<th:block th:fragment="fileSelector(name, multiple)" th:with="accept=${accept} ?: '*/*', inputText=${inputText} ?: #{pdfPrompt}, remoteCall=${remoteCall} ?: 'true', notRequired=${notRequired} ?: false">
|
<th:block th:fragment="fileSelector(name, multiple)" th:with="accept=${accept} ?: '*/*', inputText=${inputText} ?: #{pdfPrompt}, remoteCall=${remoteCall} ?: 'true', notRequired=${notRequired} ?: false">
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
const pdfPasswordPrompt = /*[[#{error.pdfPassword}]]]*/ '';
|
const pdfPasswordPrompt =/*[[#{error.pdfPassword}]]*/ '';
|
||||||
</script>
|
</script>
|
||||||
<script src="js/downloader.js"></script>
|
<script src="js/downloader.js"></script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue