Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5774a22b64 | ||
|
|
39345bb6bb | ||
|
|
57b483047e | ||
|
|
0fb7633da8 | ||
|
|
dae2f33772 |
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'stirling.software'
|
||||
version = '0.17.0'
|
||||
version = '0.17.1'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -55,8 +55,9 @@ public class PdfOverlayController {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
overlay.overlay(overlayGuide).save(outputStream);
|
||||
byte[] data = outputStream.toByteArray();
|
||||
|
||||
return WebResponseUtils.bytesToWebResponse(data, "overlaid.pdf", MediaType.APPLICATION_PDF);
|
||||
String outputFilename = baseFile.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_overlayed.pdf"; // Remove file extension and append .pdf
|
||||
|
||||
return WebResponseUtils.bytesToWebResponse(data, outputFilename, MediaType.APPLICATION_PDF);
|
||||
}
|
||||
} finally {
|
||||
for (File overlayPdfFile : overlayPdfFiles) {
|
||||
@@ -84,17 +85,20 @@ public class PdfOverlayController {
|
||||
}
|
||||
|
||||
private void sequentialOverlay(Map<Integer, String> overlayGuide, File[] overlayFiles, int basePageCount) throws IOException {
|
||||
int currentPage = 1;
|
||||
for (File overlayFile : overlayFiles) {
|
||||
try (PDDocument overlayPdf = PDDocument.load(overlayFile)) {
|
||||
for (int i = 0; i < overlayPdf.getNumberOfPages(); i++) {
|
||||
if (currentPage > basePageCount) break;
|
||||
overlayGuide.put(currentPage++, overlayFile.getAbsolutePath());
|
||||
}
|
||||
if (overlayFiles.length != 1 || basePageCount != PDDocument.load(overlayFiles[0]).getNumberOfPages()) {
|
||||
throw new IllegalArgumentException("Overlay file count and base page count must match for sequential overlay.");
|
||||
}
|
||||
|
||||
File overlayFile = overlayFiles[0];
|
||||
try (PDDocument overlayPdf = PDDocument.load(overlayFile)) {
|
||||
for (int i = 1; i <= overlayPdf.getNumberOfPages(); i++) {
|
||||
if (i > basePageCount) break;
|
||||
overlayGuide.put(i, overlayFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void interleavedOverlay(Map<Integer, String> overlayGuide, File[] overlayFiles, int basePageCount) throws IOException {
|
||||
for (int i = 0; i < basePageCount; i++) {
|
||||
File overlayFile = overlayFiles[i % overlayFiles.length];
|
||||
|
||||
@@ -42,10 +42,10 @@ public class SplitPdfBySectionsController {
|
||||
PDDocument sourceDocument = PDDocument.load(file.getInputStream());
|
||||
|
||||
// Process the PDF based on split parameters
|
||||
int horiz = request.getHorizontalDivisions();
|
||||
int verti = request.getVerticalDivisions();
|
||||
int horiz = request.getHorizontalDivisions() + 1;
|
||||
int verti = request.getVerticalDivisions() + 1;
|
||||
|
||||
List<PDDocument> splitDocuments = splitPdfPages(sourceDocument, horiz, verti);
|
||||
List<PDDocument> splitDocuments = splitPdfPages(sourceDocument, verti, horiz);
|
||||
for (PDDocument doc : splitDocuments) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
doc.save(baos);
|
||||
@@ -108,7 +108,7 @@ public class SplitPdfBySectionsController {
|
||||
try (PDPageContentStream contentStream = new PDPageContentStream(subDoc, subPage)) {
|
||||
// Set clipping area and position
|
||||
float translateX = -subPageWidth * i;
|
||||
float translateY = height - subPageHeight * (j + 1) - subPageHeight;
|
||||
float translateY = height - subPageHeight * (verticalDivisions - j);
|
||||
|
||||
contentStream.saveGraphicsState();
|
||||
contentStream.addRect(0, 0, subPageWidth, subPageHeight);
|
||||
@@ -129,6 +129,7 @@ public class SplitPdfBySectionsController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ adminUserSettings.submit=Ajouter
|
||||
# HOME-PAGE #
|
||||
#############
|
||||
home.desc=Votre application Web hébergée localement pour répondre à tous vos besoins PDF.
|
||||
home.searchBar=Search for features...
|
||||
home.searchBar=Rechercher des fonctionnalités...
|
||||
|
||||
|
||||
home.viewPdf.title=Visionner le PDF
|
||||
@@ -336,18 +336,18 @@ home.autoRedact.title=Caviarder automatiquement
|
||||
home.autoRedact.desc=Caviardez automatiquement les informations sensibles d\u2019un PDF.
|
||||
showJS.tags=caviarder,redact,auto
|
||||
|
||||
home.tableExtraxt.title=PDF to CSV
|
||||
home.tableExtraxt.desc=Extracts Tables from a PDF converting it to CSV
|
||||
home.tableExtraxt.title=PDF en CSV
|
||||
home.tableExtraxt.desc=Extrait les tableaux d\u2019un PDF et les transforme en CSV
|
||||
tableExtraxt.tags=CSV,Table Extraction,extract,convert
|
||||
|
||||
|
||||
home.autoSizeSplitPDF.title=Auto Split by Size/Count
|
||||
home.autoSizeSplitPDF.desc=Split a single PDF into multiple documents based on size, page count, or document count
|
||||
home.autoSizeSplitPDF.title=Séparer automatiquement par taille/nombre
|
||||
home.autoSizeSplitPDF.desc=Séparer un PDF unique en plusieurs documents en fonction de la taille, du nombre de pages ou du nombre de documents.
|
||||
autoSizeSplitPDF.tags=pdf,split,document,organization
|
||||
|
||||
|
||||
home.overlay-pdfs.title=Overlay PDFs
|
||||
home.overlay-pdfs.desc=Overlays PDFs on-top of another PDF
|
||||
home.overlay-pdfs.title=Incrustation de PDF
|
||||
home.overlay-pdfs.desc=Incrustation d\u2019un PDF sur un autre PDF
|
||||
overlay-pdfs.tags=Overlay
|
||||
|
||||
home.split-by-sections.title=Split PDF by Sections
|
||||
@@ -453,7 +453,7 @@ addPageNumbers.selectText.5=Pages à numéroter
|
||||
addPageNumbers.selectText.6=Texte personnalisé
|
||||
addPageNumbers.customTextDesc=Texte personnalisé
|
||||
addPageNumbers.numberPagesDesc=Quelles pages numéroter, par défaut 'all' (toutes les pages), accepte également 1-5 ou 2,5,9, etc.
|
||||
addPageNumbers.customNumberDesc=La valeur par défaut est '{n}', accepte également 'Page {n} sur {total}', 'Texte-{n}', '{filename}-{n}
|
||||
addPageNumbers.customNumberDesc=La valeur par défaut est '{n}', accepte également 'Page {n} sur {total}', 'Texte-{n}', '{filename}-{n}'
|
||||
addPageNumbers.submit=Ajouter les numéros de page
|
||||
|
||||
|
||||
@@ -845,41 +845,41 @@ PDFToXML.submit=Convertir
|
||||
#PDFToCSV
|
||||
PDFToCSV.title=PDF en CSV
|
||||
PDFToCSV.header=PDF en CSV
|
||||
PDFToCSV.prompt=Choose page to extract table
|
||||
PDFToCSV.prompt=Choisir la page pour en extraire le tableau
|
||||
PDFToCSV.submit=Extrait
|
||||
|
||||
#split-by-size-or-count
|
||||
split-by-size-or-count.header=Split PDF by Size or Count
|
||||
split-by-size-or-count.type.label=Select Split Type
|
||||
split-by-size-or-count.type.size=By Size
|
||||
split-by-size-or-count.type.pageCount=By Page Count
|
||||
split-by-size-or-count.type.docCount=By Document Count
|
||||
split-by-size-or-count.value.label=Enter Value
|
||||
split-by-size-or-count.value.placeholder=Enter size (e.g., 2MB or 3KB) or count (e.g., 5)
|
||||
split-by-size-or-count.submit=Submit
|
||||
split-by-size-or-count.header=Séparer le PDF par taille ou par nombre
|
||||
split-by-size-or-count.type.label=Sélectionner le type de division
|
||||
split-by-size-or-count.type.size=Par taille
|
||||
split-by-size-or-count.type.pageCount=Par nombre de pages
|
||||
split-by-size-or-count.type.docCount=Par nombre de documents
|
||||
split-by-size-or-count.value.label=Entrer la valeur
|
||||
split-by-size-or-count.value.placeholder=Saisir la taille (par exemple, 2MB ou 3KB) ou le nombre (par exemple, 5)
|
||||
split-by-size-or-count.submit=Séparer
|
||||
|
||||
|
||||
#overlay-pdfs
|
||||
overlay-pdfs.header=Overlay PDF Files
|
||||
overlay-pdfs.baseFile.label=Select Base PDF File
|
||||
overlay-pdfs.overlayFiles.label=Select Overlay PDF Files
|
||||
overlay-pdfs.baseFile.label=Sélectionner le fichier PDF de base
|
||||
overlay-pdfs.overlayFiles.label=Sélectionner les fichiers PDF à superposer
|
||||
overlay-pdfs.mode.label=Select Overlay Mode
|
||||
overlay-pdfs.mode.sequential=Sequential Overlay
|
||||
overlay-pdfs.mode.interleaved=Interleaved Overlay
|
||||
overlay-pdfs.mode.fixedRepeat=Fixed Repeat Overlay
|
||||
overlay-pdfs.counts.label=Overlay Counts (for Fixed Repeat Mode)
|
||||
overlay-pdfs.mode.fixedRepeat=Superposition à répétition fixe
|
||||
overlay-pdfs.counts.label=Nombre de superpositions (pour le mode de répétition fixe)
|
||||
overlay-pdfs.counts.placeholder=Enter comma-separated counts (e.g., 2,3,1)
|
||||
overlay-pdfs.position.label=Select Overlay Position
|
||||
overlay-pdfs.position.foreground=Foreground
|
||||
overlay-pdfs.position.background=Background
|
||||
overlay-pdfs.position.foreground=Premier plan
|
||||
overlay-pdfs.position.background=Arrière-plan
|
||||
overlay-pdfs.submit=Submit
|
||||
|
||||
|
||||
#split-by-sections
|
||||
split-by-sections.title=Split PDF by Sections
|
||||
split-by-sections.header=Split PDF into Sections
|
||||
split-by-sections.horizontal.label=Horizontal Divisions
|
||||
split-by-sections.vertical.label=Vertical Divisions
|
||||
split-by-sections.horizontal.placeholder=Enter number of horizontal divisions
|
||||
split-by-sections.vertical.placeholder=Enter number of vertical divisions
|
||||
split-by-sections.submit=Split PDF
|
||||
split-by-sections.title=Diviser le PDF en sections
|
||||
split-by-sections.header=Diviser le PDF en sections
|
||||
split-by-sections.horizontal.label=Divisions horizontales
|
||||
split-by-sections.vertical.label=Divisions verticales
|
||||
split-by-sections.horizontal.placeholder=Saisir le nombre de divisions horizontales
|
||||
split-by-sections.vertical.placeholder=Entrer le nombre de divisions verticales
|
||||
split-by-sections.submit=Diviser le PDF
|
||||
|
||||
@@ -17,13 +17,70 @@
|
||||
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
|
||||
|
||||
<label for="horizontalDivisions" th:text="#{split-by-sections.horizontal.label}">Horizontal Divisions</label>
|
||||
<input type="number" id="horizontalDivisions" name="horizontalDivisions" class="form-control" min="1" required th:placeholder="#{split-by-sections.horizontal.placeholder}">
|
||||
<input type="number" id="horizontalDivisions" name="horizontalDivisions" class="form-control" min="0" max="300" value="0" required th:placeholder="#{split-by-sections.horizontal.placeholder}">
|
||||
<br>
|
||||
|
||||
<label for="verticalDivisions" th:text="#{split-by-sections.vertical.label}">Vertical Divisions</label>
|
||||
<input type="number" id="verticalDivisions" name="verticalDivisions" class="form-control" min="1" required th:placeholder="#{split-by-sections.vertical.placeholder}">
|
||||
<input type="number" id="verticalDivisions" name="verticalDivisions" class="form-control" min="0" max="300" required value="1" th:placeholder="#{split-by-sections.vertical.placeholder}">
|
||||
<br>
|
||||
|
||||
<style>
|
||||
.pdf-visual-aid {
|
||||
width: 150px; /* Adjust as needed */
|
||||
height: 200px; /* Adjust as needed */
|
||||
border: 1px solid black; /* Represents the PDF page */
|
||||
position: relative;
|
||||
}
|
||||
.line {
|
||||
position: absolute;
|
||||
background-color: red; /* Line color */
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div id="pdfVisualAid" class="pdf-visual-aid"></div>
|
||||
<Script>
|
||||
function updateVisualAid() {
|
||||
const horizontalDivisions = document.getElementById('horizontalDivisions').value;
|
||||
const verticalDivisions = document.getElementById('verticalDivisions').value;
|
||||
const aid = document.getElementById('pdfVisualAid');
|
||||
|
||||
if(horizontalDivisions > 300)
|
||||
horizontalDivisions = 300
|
||||
if(verticalDivisions > 300)
|
||||
verticalDivisions = 300
|
||||
// Clear existing lines
|
||||
aid.innerHTML = '';
|
||||
|
||||
// Add horizontal lines
|
||||
for (let i = 0; i < horizontalDivisions; i++) {
|
||||
const line = document.createElement('div');
|
||||
line.classList.add('line');
|
||||
line.style.width = '100%';
|
||||
line.style.height = '1px';
|
||||
line.style.top = `${((i + 1) / (parseInt(horizontalDivisions) + 1)) * 100}%`;
|
||||
aid.appendChild(line);
|
||||
}
|
||||
|
||||
// Add vertical lines
|
||||
for (let i = 0; i < verticalDivisions; i++) {
|
||||
const line = document.createElement('div');
|
||||
line.classList.add('line');
|
||||
line.style.height = '100%';
|
||||
line.style.width = '1px';
|
||||
line.style.left = `${((i + 1) / (parseInt(verticalDivisions) + 1)) * 100}%`;
|
||||
aid.appendChild(line);
|
||||
}
|
||||
}
|
||||
|
||||
// Event listeners
|
||||
document.getElementById('horizontalDivisions').addEventListener('input', updateVisualAid);
|
||||
document.getElementById('verticalDivisions').addEventListener('input', updateVisualAid);
|
||||
|
||||
// Initial draw
|
||||
updateVisualAid();
|
||||
|
||||
</Script>
|
||||
</br>
|
||||
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{split-by-sections.submit}">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user