Cache form inputs between runs (#1066)

* Changes!

* lang
This commit is contained in:
Anthony Stirling 2024-04-20 14:46:49 +01:00 committed by GitHub
parent 73f90885b4
commit 06a178cc03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 569 additions and 168 deletions

View file

@ -4,8 +4,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@ -41,117 +39,137 @@ public class SplitPdfBySizeController {
+ " if 10MB and each page is 1MB and you enter 2MB then 5 docs each 2MB (rounded so that it accepts 1.9MB but not 2.1MB) Input:PDF Output:ZIP-PDF Type:SISO")
public ResponseEntity<byte[]> autoSplitPdf(@ModelAttribute SplitPdfBySizeOrCountRequest request)
throws Exception {
List<ByteArrayOutputStream> splitDocumentsBoas = new ArrayList<ByteArrayOutputStream>();
MultipartFile file = request.getFileInput();
PDDocument sourceDocument = Loader.loadPDF(file.getBytes());
// 0 = size, 1 = page count, 2 = doc count
int type = request.getSplitType();
String value = request.getSplitValue();
if (type == 0) { // Split by size
long maxBytes = GeneralUtils.convertSizeToBytes(value);
long currentSize = 0;
PDDocument currentDoc = new PDDocument();
for (PDPage page : sourceDocument.getPages()) {
ByteArrayOutputStream pageOutputStream = new ByteArrayOutputStream();
PDDocument tempDoc = new PDDocument();
tempDoc.addPage(page);
tempDoc.save(pageOutputStream);
tempDoc.close();
long pageSize = pageOutputStream.size();
if (currentSize + pageSize > maxBytes) {
// Save and reset current document
splitDocumentsBoas.add(currentDocToByteArray(currentDoc));
currentDoc = new PDDocument();
currentSize = 0;
}
currentDoc.addPage(page);
currentSize += pageSize;
}
// Add the last document if it contains any pages
if (currentDoc.getPages().getCount() != 0) {
splitDocumentsBoas.add(currentDocToByteArray(currentDoc));
}
} else if (type == 1) { // Split by page count
int pageCount = Integer.parseInt(value);
int currentPageCount = 0;
PDDocument currentDoc = new PDDocument();
for (PDPage page : sourceDocument.getPages()) {
currentDoc.addPage(page);
currentPageCount++;
if (currentPageCount == pageCount) {
// Save and reset current document
splitDocumentsBoas.add(currentDocToByteArray(currentDoc));
currentDoc = new PDDocument();
currentPageCount = 0;
}
}
// Add the last document if it contains any pages
if (currentDoc.getPages().getCount() != 0) {
splitDocumentsBoas.add(currentDocToByteArray(currentDoc));
}
} else if (type == 2) { // Split by doc count
int documentCount = Integer.parseInt(value);
int totalPageCount = sourceDocument.getNumberOfPages();
int pagesPerDocument = totalPageCount / documentCount;
int extraPages = totalPageCount % documentCount;
int currentPageIndex = 0;
for (int i = 0; i < documentCount; i++) {
PDDocument currentDoc = new PDDocument();
int pagesToAdd = pagesPerDocument + (i < extraPages ? 1 : 0);
for (int j = 0; j < pagesToAdd; j++) {
currentDoc.addPage(sourceDocument.getPage(currentPageIndex++));
}
splitDocumentsBoas.add(currentDocToByteArray(currentDoc));
}
} else {
throw new IllegalArgumentException("Invalid argument for split type");
}
sourceDocument.close();
Path zipFile = Files.createTempFile("split_documents", ".zip");
String filename =
Filenames.toSimpleFileName(file.getOriginalFilename())
.replaceFirst("[.][^.]+$", "");
byte[] data;
byte[] data = null;
try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile));
PDDocument sourceDocument = Loader.loadPDF(file.getBytes())) {
try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile))) {
for (int i = 0; i < splitDocumentsBoas.size(); i++) {
String fileName = filename + "_" + (i + 1) + ".pdf";
ByteArrayOutputStream baos = splitDocumentsBoas.get(i);
byte[] pdf = baos.toByteArray();
int type = request.getSplitType();
String value = request.getSplitValue();
ZipEntry pdfEntry = new ZipEntry(fileName);
zipOut.putNextEntry(pdfEntry);
zipOut.write(pdf);
zipOut.closeEntry();
if (type == 0) {
long maxBytes = GeneralUtils.convertSizeToBytes(value);
handleSplitBySize(sourceDocument, maxBytes, zipOut, filename);
} else if (type == 1) {
int pageCount = Integer.parseInt(value);
handleSplitByPageCount(sourceDocument, pageCount, zipOut, filename);
} else if (type == 2) {
int documentCount = Integer.parseInt(value);
handleSplitByDocCount(sourceDocument, documentCount, zipOut, filename);
} else {
throw new IllegalArgumentException("Invalid argument for split type");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
data = Files.readAllBytes(zipFile);
Files.delete(zipFile);
Files.deleteIfExists(zipFile);
}
return WebResponseUtils.bytesToWebResponse(
data, filename + ".zip", MediaType.APPLICATION_OCTET_STREAM);
}
private ByteArrayOutputStream currentDocToByteArray(PDDocument document) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
document.save(baos);
document.close();
return baos;
private void handleSplitBySize(
PDDocument sourceDocument, long maxBytes, ZipOutputStream zipOut, String baseFilename)
throws IOException {
long currentSize = 0;
PDDocument currentDoc = new PDDocument();
int fileIndex = 1;
for (int pageIndex = 0; pageIndex < sourceDocument.getNumberOfPages(); pageIndex++) {
PDPage page = sourceDocument.getPage(pageIndex);
ByteArrayOutputStream pageOutputStream = new ByteArrayOutputStream();
try (PDDocument tempDoc = new PDDocument()) {
PDPage importedPage = tempDoc.importPage(page); // This creates a new PDPage object
tempDoc.save(pageOutputStream);
}
long pageSize = pageOutputStream.size();
if (currentSize + pageSize > maxBytes) {
if (currentDoc.getNumberOfPages() > 0) {
saveDocumentToZip(currentDoc, zipOut, baseFilename, fileIndex++);
currentDoc.close(); // Make sure to close the document
currentDoc = new PDDocument();
currentSize = 0;
}
}
PDPage newPage = new PDPage(page.getCOSObject()); // Re-create the page
currentDoc.addPage(newPage);
currentSize += pageSize;
}
if (currentDoc.getNumberOfPages() != 0) {
saveDocumentToZip(currentDoc, zipOut, baseFilename, fileIndex++);
currentDoc.close();
}
}
private void handleSplitByPageCount(
PDDocument sourceDocument, int pageCount, ZipOutputStream zipOut, String baseFilename)
throws IOException {
int currentPageCount = 0;
PDDocument currentDoc = new PDDocument();
int fileIndex = 1;
for (PDPage page : sourceDocument.getPages()) {
currentDoc.addPage(page);
currentPageCount++;
if (currentPageCount == pageCount) {
// Save and reset current document
saveDocumentToZip(currentDoc, zipOut, baseFilename, fileIndex++);
currentDoc = new PDDocument();
currentPageCount = 0;
}
}
// Add the last document if it contains any pages
if (currentDoc.getPages().getCount() != 0) {
saveDocumentToZip(currentDoc, zipOut, baseFilename, fileIndex++);
}
}
private void handleSplitByDocCount(
PDDocument sourceDocument,
int documentCount,
ZipOutputStream zipOut,
String baseFilename)
throws IOException {
int totalPageCount = sourceDocument.getNumberOfPages();
int pagesPerDocument = totalPageCount / documentCount;
int extraPages = totalPageCount % documentCount;
int currentPageIndex = 0;
int fileIndex = 1;
for (int i = 0; i < documentCount; i++) {
PDDocument currentDoc = new PDDocument();
int pagesToAdd = pagesPerDocument + (i < extraPages ? 1 : 0);
for (int j = 0; j < pagesToAdd; j++) {
currentDoc.addPage(sourceDocument.getPage(currentPageIndex++));
}
saveDocumentToZip(currentDoc, zipOut, baseFilename, fileIndex++);
}
}
private void saveDocumentToZip(
PDDocument document, ZipOutputStream zipOut, String baseFilename, int index)
throws IOException {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
document.save(outStream);
document.close(); // Close the document to free resources
// Create a new zip entry
ZipEntry zipEntry = new ZipEntry(baseFilename + "_" + index + ".pdf");
zipOut.putNextEntry(zipEntry);
zipOut.write(outStream.toByteArray());
zipOut.closeEntry();
}
}

View file

@ -139,25 +139,29 @@ public class SanitizeController {
for (PDPage page : allPages) {
PDResources res = page.getResources();
// Remove embedded files from the PDF
res.getCOSObject().removeItem(COSName.getPDFName("EmbeddedFiles"));
if (res != null && res.getCOSObject() != null) {
res.getCOSObject().removeItem(COSName.getPDFName("EmbeddedFiles"));
}
}
}
private void sanitizeMetadata(PDDocument document) {
PDMetadata metadata = document.getDocumentCatalog().getMetadata();
if (metadata != null) {
document.getDocumentCatalog().setMetadata(null);
if (document.getDocumentCatalog() != null) {
PDMetadata metadata = document.getDocumentCatalog().getMetadata();
if (metadata != null) {
document.getDocumentCatalog().setMetadata(null);
}
}
}
private void sanitizeLinks(PDDocument document) throws IOException {
for (PDPage page : document.getPages()) {
for (PDAnnotation annotation : page.getAnnotations()) {
if (annotation instanceof PDAnnotationLink) {
if (annotation != null && annotation instanceof PDAnnotationLink) {
PDAction action = ((PDAnnotationLink) annotation).getAction();
if (action instanceof PDActionLaunch || action instanceof PDActionURI) {
if (action != null
&& (action instanceof PDActionLaunch
|| action instanceof PDActionURI)) {
((PDAnnotationLink) annotation).setAction(null);
}
}
@ -167,7 +171,11 @@ public class SanitizeController {
private void sanitizeFonts(PDDocument document) {
for (PDPage page : document.getPages()) {
page.getResources().getCOSObject().removeItem(COSName.getPDFName("Font"));
if (page != null
&& page.getResources() != null
&& page.getResources().getCOSObject() != null) {
page.getResources().getCOSObject().removeItem(COSName.getPDFName("Font"));
}
}
}
}

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=تنزيل الملف
settings.zipThreshold=ملفات مضغوطة عند تجاوز عدد الملفات التي تم تنزيلها
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Изтегли файл
settings.zipThreshold=Архивирайте файловете, когато броят на изтеглените файлове надвишава
settings.signOut=Изход
settings.accountSettings=Настройки на акаунта
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Промяна на идентификационните данни
changeCreds.header=Актуализирайте данните за акаунта си
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Descarrega Arxiu
settings.zipThreshold=Comprimiu els fitxers quan el nombre de fitxers baixats superi
settings.signOut=Sortir
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Datei herunterladen
settings.zipThreshold=Dateien komprimieren, wenn die Anzahl der heruntergeladenen Dateien überschritten wird
settings.signOut=Abmelden
settings.accountSettings=Kontoeinstellungen
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Anmeldeinformationen ändern
changeCreds.header=Aktualisieren Sie Ihre Kontodaten
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Anzahl vertikaler Teiler eingeben
split-by-sections.submit=PDF teilen
split-by-sections.merge=In eine PDF zusammenfügen
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Lizenzen
licenses.title=Lizenzen von Drittanbietern

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Λήψη αρχείου
settings.zipThreshold=Αρχεία Zip όταν ο αριθμός των ληφθέντων αρχείων είναι πολύ μεγάλος
settings.signOut=Αποσύνδεση
settings.accountSettings=Ρυθμίσεις Λογαριασμού
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Αλλαγή Διαπιστευτηρίων
changeCreds.header=Ενημέρωση των λεπτομερειών του Λογαριασμού σας
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Εισαγάγετε τον αριθμό
split-by-sections.submit=Διαχωρισμός PDF
split-by-sections.merge=Συγχώνευση σε ένα PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Άδειες
licenses.title=3rd Party Άδειες

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Download file
settings.zipThreshold=Zip files when the number of downloaded files exceeds
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Download file
settings.zipThreshold=Zip files when the number of downloaded files exceeds
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Descargar el archivo
settings.zipThreshold=Archivos ZIP cuando excede el número de archivos descargados
settings.signOut=Desconectar
settings.accountSettings=Configuración de la cuenta
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Cambiar Credenciales
changeCreds.header=Actualice los detalles de su cuenta
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Introduzca el número de divisiones verti
split-by-sections.submit=Dividir PDF
split-by-sections.merge=Unir en Un PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licencias
licenses.title=Licencias de terceros

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Deskargatu fitxategia
settings.zipThreshold=ZIP fitxategiak deskargatutako fitxategi kopurua gainditzen denean
settings.signOut=Saioa itxi
settings.accountSettings=Kontuaren ezarpenak
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Télécharger le fichier
settings.zipThreshold=Compresser les fichiers en ZIP lorsque le nombre de fichiers téléchargés dépasse
settings.signOut=Déconnexion
settings.accountSettings=Paramètres du compte
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Modifiez vos identifiants
changeCreds.header=Mettez à jour vos identifiants de connexion
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Entrer le nombre de divisions verticales
split-by-sections.submit=Diviser le PDF
split-by-sections.merge=Fusionner en un seul PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licences
licenses.title=Licences tierces

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=फ़ाइल डाउनलोड करें
settings.zipThreshold=जब डाउनलोड की गई फ़ाइलों की संख्या सीमा से अधिक हो
settings.signOut=साइन आउट
settings.accountSettings=खाता सेटिंग्स
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=क्रेडेंशियल बदलें
changeCreds.header=अपना खाता विवरण अपडेट करें
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=लंबवत विभाजन की
split-by-sections.submit=PDF को विभाजित करें
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Töltse le a fájlt
settings.zipThreshold=Fájlok tömörítése, ha a letöltött fájlok száma meghaladja
settings.signOut=Kijelentkezés
settings.accountSettings=Fiókbeállítások
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Hitelesítés megváltoztatása
changeCreds.header=Frissítse fiókadatait
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Adja meg a függőleges szakaszok számá
split-by-sections.submit=Felosztás
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Unduh berkas
settings.zipThreshold=Berkas zip ketika jumlah berkas yang diunduh melebihi
settings.signOut=Keluar
settings.accountSettings=Pengaturan Akun
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Ubah Kredensial
changeCreds.header=Perbarui Detail Akun Anda
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Input angka untuk pembagian vertikal
split-by-sections.submit=Pisahkan PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Scarica file
settings.zipThreshold=Comprimi file in .zip quando il numero di download supera
settings.signOut=Logout
settings.accountSettings=Impostazioni Account
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Cambia credenziali
changeCreds.header=Aggiorna i dettagli del tuo account
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Inserire il numero di divisioni verticali
split-by-sections.submit=Dividi PDF
split-by-sections.merge=Unisci in un unico PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenze
licenses.title=Licenze di terze parti

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=ファイルをダウンロード
settings.zipThreshold=このファイル数を超えたときにファイルを圧縮する
settings.signOut=サインアウト
settings.accountSettings=アカウント設定
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=資格情報の変更
changeCreds.header=アカウントの詳細を更新する
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=垂直方向の分割数を選択
split-by-sections.submit=分割
split-by-sections.merge=1 つの PDF に結合するかどうか
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=ライセンス
licenses.title=サードパーティライセンス

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=다운로드
settings.zipThreshold=다운로드한 파일 수가 초과된 경우 파일 압축하기
settings.signOut=로그아웃
settings.accountSettings=계정 설정
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=계정 정보 변경
changeCreds.header=계정 정보 업데이트
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=수직 분할 수를 입력합니다
split-by-sections.submit=PDF 분할
split-by-sections.merge=하나의 PDF로 병합
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=라이센스
licenses.title=제3자 라이선스

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Download bestand
settings.zipThreshold=Bestanden zippen wanneer het aantal gedownloade bestanden meer is dan
settings.signOut=Uitloggen
settings.accountSettings=Account instellingen
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Inloggegevens wijzigen
changeCreds.header=Werk je accountgegevens bij
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Voer het aantal verticale secties in
split-by-sections.submit=PDF splitsen
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenties
licenses.title=Licenties van derden

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Pobierz plik
settings.zipThreshold=Spakuj pliki, gdy liczba pobranych plików przekroczy
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=⇬ Fazer download do arquivo
settings.zipThreshold=Compactar arquivos quando o número de arquivos baixados exceder
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=⇬ Fazer download do ficheiro
settings.zipThreshold=Compactar ficheiros quando o número de ficheiros baixados exceder
settings.signOut=Terminar Sessão
settings.accountSettings=Configuração de Conta
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Alterar senha
changeCreds.header=Alterar dados da sua conta
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Introduza o número de divisões verticai
split-by-sections.submit=Dividir PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenças
licenses.title=Licenças de terceiros

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Descarcă fișierul
settings.zipThreshold=Împachetează fișierele când numărul de fișiere descărcate depășește
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Загрузить файл
settings.zipThreshold=Zip-файлы, когда количество загруженных файлов превышает
settings.signOut=Выйти
settings.accountSettings=Настройки аккаунта
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Изменить учетные данные
changeCreds.header=Обновите данные вашей учетной записи
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Введите количество ве
split-by-sections.submit=Разделить PDF
split-by-sections.merge=Объединить в один PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Лицензии
licenses.title=Лицензии от третьих сторон

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Preuzmi fajl
settings.zipThreshold=Zipuj fajlove kada pređe broj preuzetih fajlova
settings.signOut=Odjava
settings.accountSettings=Podešavanja naloga
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Promeni pristupne podatke
changeCreds.header=Ažurirajte detalje svog naloga
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Unesite broj vertikalnih podele
split-by-sections.submit=Razdvoji PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Ladda ner fil
settings.zipThreshold=Zip-filer när antalet nedladdade filer överskrider
settings.signOut=Sign Out
settings.accountSettings=Account Settings
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Change Credentials
changeCreds.header=Update Your Account Details
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Enter number of vertical divisions
split-by-sections.submit=Split PDF
split-by-sections.merge=Merge Into One PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Licenses
licenses.title=3rd Party Licenses

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=Dosyayı indir
settings.zipThreshold=İndirilen dosya sayısı şu değeri aştığında zip dosyası oluştur:
settings.signOut=Oturumu Kapat
settings.accountSettings=Hesap Ayarları
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Giriş Bilgilerini Değiştir
changeCreds.header=Hesap Detaylarınızı Güncelleyin
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Dikey bölme sayısını girin
split-by-sections.submit=PDF'yi Böl
split-by-sections.merge=Bir PDF'de Birleştirin
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Lisanslar
licenses.title=3. Taraf Lisansları

View file

@ -1,7 +1,7 @@
###########
# Generic #
###########
# the direction that the language is written (ltr = left to right, rtl = right to left)
# the direction that the language is written (ltr=left to right, rtl = right to left)
language.direction=ltr
pdfPrompt=Оберіть PDF(и)
@ -120,8 +120,9 @@ settings.downloadOption.3=Завантажити файл
settings.zipThreshold=Zip-файли, коли кількість завантажених файлів перевищує
settings.signOut=Вийти
settings.accountSettings=Налаштування акаунта
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=Змінити облікові дані
changeCreds.header=Оновіть дані вашого облікового запису
@ -132,6 +133,8 @@ changeCreds.newPassword=Новий пароль
changeCreds.confirmNewPassword=Підтвердіть новий пароль
changeCreds.submit=Надіслати зміни
account.title=Налаштування акаунта
account.accountSettings=Налаштування акаунта
account.adminSettings=Налаштування адміністратора - Перегляд і додавання користувачів
@ -152,6 +155,7 @@ account.webBrowserSettings=Налаштування веб-браузера
account.syncToBrowser=Синхронізувати обліковий запис -> Браузер
account.syncToAccount=Синхронізувати обліковий запис <- Браузер
adminUserSettings.title=Налаштування контролю користувача
adminUserSettings.header=Налаштування контролю користувача адміністратора
adminUserSettings.admin=Адміністратор
@ -244,12 +248,10 @@ home.changeMetadata.title=Змінити метадані
home.changeMetadata.desc=Змінити/видалити/додати метадані з документа PDF
changeMetadata.tags=Title,author,date,creation,time,publisher,producer,stats
home.fileToPDF.title=Конвертувати файл в PDF
home.fileToPDF.desc=Конвертуйте майже будь-який файл в PDF (DOCX, PNG, XLS, PPT, TXT та інші)
fileToPDF.tags=transformation,format,document,picture,slide,text,conversion,office,docs,word,excel,powerpoint
home.ocr.title=OCR/Очищення сканування
home.ocr.desc=Очищення сканування та виявлення тексту на зображеннях у файлі PDF та повторне додавання його як текст.
ocr.tags=recognition,text,image,scan,read,identify,detection,editable
@ -403,12 +405,10 @@ home.overlay-pdfs.title=Накладення PDF
home.overlay-pdfs.desc=Накладення одного PDF поверх іншого PDF
overlay-pdfs.tags=Overlay
home.split-by-sections.title=Розділення PDF за секціями
home.split-by-sections.desc=Розділення кожної сторінки PDF на менші горизонтальні та вертикальні секції
split-by-sections.tags=Section Split, Divide, Customize
home.AddStampRequest.title=Додати печатку на PDF
home.AddStampRequest.desc=Додавання текстової або зображення печатки у вказані місця
AddStampRequest.tags=Stamp, Add image, center image, Watermark, PDF, Embed, Customize
@ -418,11 +418,11 @@ home.PDFToBook.title=PDF у книгу/комікс
home.PDFToBook.desc=Конвертує PDF у формат книги/комікса за допомогою calibre
PDFToBook.tags=Book,Comic,Calibre,Convert,manga,amazon,kindle
home.BookToPDF.title=Книга у PDF
home.BookToPDF.desc=Конвертує формати книги/комікса у PDF за допомогою calibre
BookToPDF.tags=Book,Comic,Calibre,Convert,manga,amazon,kindle
###########################
# #
# WEB PAGES #
@ -606,6 +606,7 @@ pageLayout.pagesPerSheet=Сторінок на одному аркуші:
pageLayout.addBorder=Додати рамки
pageLayout.submit=Відправити
#scalePages
scalePages.title=Відрегулювати масштаб сторінки
scalePages.header=Відрегулювати масштаб сторінки
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=Введіть кількість вер
split-by-sections.submit=Розділити PDF
split-by-sections.merge=Об'єднати в один PDF
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=Ліцензії
licenses.title=Ліцензії від третіх сторін

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=下载文件
settings.zipThreshold=当下载的文件数量超过限制时,将文件压缩。
settings.signOut=登出
settings.accountSettings=帐号设定
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=更改凭证
changeCreds.header=更新您的账户详情
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=输入垂直分割数
split-by-sections.submit=分割PDF
split-by-sections.merge=是否合并为一个pdf
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=许可证
licenses.title=第三方许可证

View file

@ -120,8 +120,9 @@ settings.downloadOption.3=下載檔案
settings.zipThreshold=當下載的檔案數量超過時,壓縮檔案
settings.signOut=登出
settings.accountSettings=帳戶設定
settings.bored.help=Enables easter egg game
settings.cacheInputs.name=Save form inputs
settings.cacheInputs.help=Enable to store previously used inputs for future runs
changeCreds.title=變更憑證
changeCreds.header=更新您的帳戶詳細資訊
@ -1022,6 +1023,15 @@ split-by-sections.vertical.placeholder=輸入垂直劃分的數量
split-by-sections.submit=分割 PDF
split-by-sections.merge=是否合併為一個pdf
#printFile
printFile.title=Print File
printFile.header=Print File to Printer
printFile.selectText.1=Select File to Print
printFile.selectText.2=Enter Printer Name
printFile.submit=Print
#licenses
licenses.nav=許可證
licenses.title=第三方許可證

View file

@ -0,0 +1,82 @@
document.addEventListener("DOMContentLoaded", function() {
var cacheInputs = localStorage.getItem("cacheInputs") || "disabled";
if (cacheInputs !== "enabled") {
return; // Stop execution if caching is not enabled
}
// Function to generate a key based on the form's action attribute
function generateStorageKey(form) {
const action = form.getAttribute('action');
if (!action || action.length < 3) {
return null; // Not a valid action, return null to skip processing
}
return 'formData_' + encodeURIComponent(action);
}
// Function to save form data to localStorage
function saveFormData(form) {
const formKey = generateStorageKey(form);
if (!formKey) return; // Skip if no valid key
const formData = {};
const elements = form.elements;
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
// Skip elements without names, passwords, files, hidden fields, and submit/reset buttons
if (!element.name ||
element.type === 'password' ||
element.type === 'file' ||
//element.type === 'hidden' ||
element.type === 'submit' ||
element.type === 'reset') {
continue;
}
// Handle checkboxes: store only if checked
if (element.type === 'checkbox') {
if (element.checked) {
formData[element.name] = element.value;
} else {
continue; // Skip unchecked boxes
}
} else {
// Skip saving empty values
if (element.value === "" || element.value == null) {
continue;
}
formData[element.name] = element.value;
}
}
localStorage.setItem(formKey, JSON.stringify(formData));
}
// Function to load form data from localStorage
function loadFormData(form) {
const formKey = generateStorageKey(form);
if (!formKey) return; // Skip if no valid key
const savedData = localStorage.getItem(formKey);
if (savedData) {
const formData = JSON.parse(savedData);
for (const key in formData) {
if (formData.hasOwnProperty(key) && form.elements[key]) {
const element = form.elements[key];
if (element.type === 'checkbox') {
element.checked = true;
} else {
element.value = formData[key];
}
}
}
}
}
// Attach event listeners and load data for all forms
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', function(event) {
saveFormData(form);
});
loadFormData(form);
});
});

View file

@ -31,3 +31,12 @@ document.getElementById("boredWaiting").addEventListener("change", function () {
boredWaiting = this.checked ? "enabled" : "disabled";
localStorage.setItem("boredWaiting", boredWaiting);
});
var cacheInputs = localStorage.getItem("cacheInputs") || "disabled";
document.getElementById("cacheInputs").checked = cacheInputs === "enabled";
document.getElementById("cacheInputs").addEventListener("change", function () {
cacheInputs = this.checked ? "enabled" : "disabled";
localStorage.setItem("cacheInputs", cacheInputs);
});

View file

@ -60,7 +60,7 @@
<!-- Help Modal -->
<link rel="stylesheet" href="css/errorBanner.css">
<script src="js/cacheFormInputs.js"></script>
<script src="js/tab-container.js"></script>
<script src="js/darkmode.js"></script>
</th:block>

View file

@ -210,9 +210,13 @@
<span id="zipThresholdValue" class="ms-2"></span>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="boredWaiting">
<input type="checkbox" class="form-check-input" id="boredWaiting" th:title="#{settings.bored.help}">
<label class="form-check-label" for="boredWaiting" th:text="#{bored}"></label>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="cacheInputs" th:title="#{settings.cacheInputs.help}">
<label class="form-check-label" for="cacheInputs" th:text="#{settings.cacheInputs.name}"></label>
</div>
<a th:if="${@loginEnabled}" href="account" class="btn btn-sm btn-outline-primary" role="button" th:text="#{settings.accountSettings}" target="_blank">Account Settings</a>
</div>
<div class="modal-footer">