Compare commits

...

7 Commits

Author SHA1 Message Date
Anthony Stirling
3bffc1da76 gradle changes 2023-12-18 14:58:06 +00:00
Anthony Stirling
631d3948bd fix for #531 plus seperated out some things 2023-12-18 14:52:18 +00:00
Anthony Stirling
5774a22b64 possible fixes for overlay 2023-12-17 12:35:50 +00:00
ant
39345bb6bb Merge branch 'main' of git@github.com:Frooodle/Stirling-PDF.git into main 2023-12-17 12:31:24 +00:00
Anthony Stirling
57b483047e splitPdf sections cleanup 2023-12-17 12:23:11 +00:00
Anthony Stirling
0fb7633da8 Merge pull request #528 from NicolasFR/lang/FR_fr-updates
lang: update fr_FR
2023-12-17 11:34:09 +00:00
Nicolas
dae2f33772 lang: update fr_FR 2023-12-17 10:39:33 +01:00
13 changed files with 185 additions and 80 deletions

View File

@@ -30,12 +30,18 @@ RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /configs /customFiles
# chown -R stirlingpdfuser:stirlingpdfgroup /usr/share/fonts/opentype/noto /configs /customFiles
# Copy necessary files
COPY ./scripts/download-security-jar.sh /scripts/download-security-jar.sh
COPY ./scripts/init-without-ocr.sh /scripts/init-without-ocr.sh
COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto/
COPY src/main/resources/static/fonts/*.otf /usr/share/fonts/opentype/noto/
COPY build/libs/*.jar app.jar
# Set font cache and permissions
RUN fc-cache -f -v
RUN fc-cache -f -v && \
chmod +x /scripts/init-without-ocr.sh && \
chmod +x /scripts/download-security-jar.sh
# chown stirlingpdfuser:stirlingpdfgroup /app.jar
@@ -50,5 +56,5 @@ ENV DOCKER_ENABLE_SECURITY=false
# Run the application
#USER stirlingpdfuser
ENTRYPOINT ["/scripts/init.sh"]
ENTRYPOINT ["/scripts/init-without-ocr.sh"]
CMD ["java", "-jar", "/app.jar"]

View File

@@ -19,19 +19,25 @@ ENV DOCKER_ENABLE_SECURITY=false \
# chown -R stirlingpdfuser:stirlingpdfgroup /scripts /configs /customFiles
RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /configs /customFiles
COPY ./scripts/download-security-jar.sh /scripts/download-security-jar.sh
COPY ./scripts/init-without-ocr.sh /scripts/init-without-ocr.sh
COPY build/libs/*.jar app.jar
# Set font cache and permissions
#RUN chown stirlingpdfuser:stirlingpdfgroup /app.jar
RUN chmod +x /scripts/init-without-ocr.sh && \
chmod +x /scripts/download-security-jar.sh && \
apk add --no-cache curl
# Expose the application port
EXPOSE 8080
# Set environment variables
ENV ENDPOINTS_GROUPS_TO_REMOVE=CLI
ENTRYPOINT ["/scripts/init.sh"]
ENTRYPOINT ["/scripts/init-without-ocr.sh"]
# Run the application
CMD ["java", "-jar", "/app.jar"]

View File

@@ -19,6 +19,7 @@ add-image | ✔️ | ✔️ | ✔️
add-watermark | ✔️ | ✔️ | ✔️
adjust-contrast | ✔️ | ✔️ | ✔️
auto-split-pdf | ✔️ | ✔️ | ✔️
auto-redact | ✔️ | ✔️ | ✔️
auto-rename | ✔️ | ✔️ | ✔️
cert-sign | ✔️ | ✔️ | ✔️
crop | ✔️ | ✔️ | ✔️
@@ -33,7 +34,9 @@ img-to-pdf | ✔️ | ✔️ | ✔️
markdown-to-pdf | ✔️ | ✔️ | ✔️
merge-pdfs | ✔️ | ✔️ | ✔️
multi-page-layout | ✔️ | ✔️ | ✔️
overlay-pdf | ✔️ | ✔️ | ✔️
pdf-organizer | ✔️ | ✔️ | ✔️
pdf-to-csv | ✔️ | ✔️ | ✔️
pdf-to-img | ✔️ | ✔️ | ✔️
pdf-to-single-page | ✔️ | ✔️ | ✔️
remove-pages | ✔️ | ✔️ | ✔️
@@ -43,6 +46,8 @@ sanitize-pdf | ✔️ | ✔️ | ✔️
scale-pages | ✔️ | ✔️ | ✔️
sign | ✔️ | ✔️ | ✔️
show-javascript | ✔️ | ✔️ | ✔️
split-by-size-or-count | ✔️ | ✔️ | ✔️
split-pdf-by-sections | ✔️ | ✔️ | ✔️
split-pdfs | ✔️ | ✔️ | ✔️
file-to-pdf | | ✔️ | ✔️
pdf-to-html | | ✔️ | ✔️

View File

@@ -2,13 +2,13 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.springdoc.openapi-gradle-plugin' version '1.6.0'
id 'org.springdoc.openapi-gradle-plugin' version '1.8.0'
id "io.swagger.swaggerhub" version "1.2.0"
id 'edu.sc.seis.launch4j' version '3.0.5'
}
group = 'stirling.software'
version = '0.17.0'
version = '0.17.2'
sourceCompatibility = '17'
repositories {
@@ -32,7 +32,6 @@ sourceSets {
}
}
openApi {
apiDocsUrl = "http://localhost:8080/v1/api-docs"
outputDir = file("$projectDir")
@@ -87,15 +86,24 @@ dependencies {
implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4'
implementation 'com.github.jai-imageio:jai-imageio-core:1.4.0'
implementation 'com.github.jai-imageio:jai-imageio-jpeg2000:1.3.0'
implementation 'commons-io:commons-io:2.13.0'
implementation 'commons-io:commons-io:2.15.1'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
//general PDF
// https://mvnrepository.com/artifact/com.opencsv/opencsv
implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'
implementation 'org.apache.pdfbox:pdfbox:2.0.29'
implementation 'org.apache.pdfbox:xmpbox:2.0.29'
implementation ('com.opencsv:opencsv:5.7.1') {
exclude group: 'commons-logging', module: 'commons-logging'
}
implementation ('org.apache.pdfbox:pdfbox:2.0.29'){
exclude group: 'commons-logging', module: 'commons-logging'
}
implementation ('org.apache.pdfbox:xmpbox:2.0.29'){
exclude group: 'commons-logging', module: 'commons-logging'
}
implementation 'org.bouncycastle:bcprov-jdk18on:1.77'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.77'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
@@ -107,7 +115,7 @@ dependencies {
implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0'
developmentOnly("org.springframework.boot:spring-boot-devtools")
compileOnly 'org.projectlombok:lombok:1.18.28'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.28'
}

View File

@@ -0,0 +1,19 @@
echo "Running Stirling PDF with DOCKER_ENABLE_SECURITY=${DOCKER_ENABLE_SECURITY} and VERSION_TAG=${VERSION_TAG}"
# Check for DOCKER_ENABLE_SECURITY and download the appropriate JAR if required
if [ "$DOCKER_ENABLE_SECURITY" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then
if [ ! -f app-security.jar ]; then
echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar"
curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar
# If the first download attempt failed, try with the 'v' prefix
if [ $? -ne 0 ]; then
echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar"
curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar
fi
if [ $? -eq 0 ]; then # checks if curl was successful
rm -f app.jar
ln -s app-security.jar app.jar
fi
fi
fi

View File

@@ -0,0 +1,6 @@
#!/bin/sh
/scripts/download-security-jar.sh
# Run the main command
exec "$@"

View File

@@ -3,7 +3,7 @@
# Copy the original tesseract-ocr files to the volume directory without overwriting existing files
echo "Copying original files without overwriting existing files"
mkdir -p /usr/share/tesseract-ocr
cp -rn /usr/share/tesseract-ocr-original/* /usr/share/tesseract-ocr
cp -rn /usr/share/tesseract-ocr-original/* /usr/share/tesseract-ocr
if [ -d /usr/share/tesseract-ocr/4.00/tessdata ]; then
cp -r /usr/share/tesseract-ocr/4.00/tessdata/* /usr/share/tesseract-ocr/5/tessdata/ || true;
@@ -20,26 +20,7 @@ if [[ -n "$TESSERACT_LANGS" ]]; then
done
fi
echo "Running Stirling PDF with DOCKER_ENABLE_SECURITY=${DOCKER_ENABLE_SECURITY} and VERSION_TAG=${VERSION_TAG}"
# Check for DOCKER_ENABLE_SECURITY and download the appropriate JAR if required
if [ "$DOCKER_ENABLE_SECURITY" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then
if [ ! -f app-security.jar ]; then
echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar"
curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar
# If the first download attempt failed, try with the 'v' prefix
if [ $? -ne 0 ]; then
echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar"
curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar
fi
if [ $? -eq 0 ]; then # checks if curl was successful
rm -f app.jar
ln -s app-security.jar app.jar
fi
fi
fi
/scripts/download-security-jar.sh
# Run the main command
exec "$@"

View File

@@ -81,6 +81,10 @@ public class EndpointConfiguration {
addEndpointToGroup("PageOps", "auto-split-pdf");
addEndpointToGroup("PageOps", "extract-page");
addEndpointToGroup("PageOps", "pdf-to-single-page");
addEndpointToGroup("PageOps", "split-by-size-or-count");
addEndpointToGroup("PageOps", "overlay-pdf");
addEndpointToGroup("PageOps", "split-pdf-by-sections");
// Adding endpoints to "Convert" group
addEndpointToGroup("Convert", "pdf-to-img");
@@ -96,6 +100,8 @@ public class EndpointConfiguration {
addEndpointToGroup("Convert", "html-to-pdf");
addEndpointToGroup("Convert", "url-to-pdf");
addEndpointToGroup("Convert", "markdown-to-pdf");
addEndpointToGroup("Convert", "pdf-to-csv");
// Adding endpoints to "Security" group
addEndpointToGroup("Security", "add-password");
@@ -104,6 +110,7 @@ public class EndpointConfiguration {
addEndpointToGroup("Security", "add-watermark");
addEndpointToGroup("Security", "cert-sign");
addEndpointToGroup("Security", "sanitize-pdf");
addEndpointToGroup("Security", "auto-redact");
// Adding endpoints to "Other" group
@@ -197,6 +204,11 @@ public class EndpointConfiguration {
addEndpointToGroup("Java", "pdf-to-single-page");
addEndpointToGroup("Java", "markdown-to-pdf");
addEndpointToGroup("Java", "show-javascript");
addEndpointToGroup("Java", "auto-redact");
addEndpointToGroup("Java", "pdf-to-csv");
addEndpointToGroup("Java", "split-by-size-or-count");
addEndpointToGroup("Java", "overlay-pdf");
addEndpointToGroup("Java", "split-pdf-by-sections");
//Javascript
addEndpointToGroup("Javascript", "pdf-organizer");

View File

@@ -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];

View File

@@ -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 {
}
}

View File

@@ -16,7 +16,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover and keep 7 days' worth of history -->
<fileNamePattern>auth-%d{MM-dd-yyyy}.log</fileNamePattern>
<fileNamePattern>logs/auth-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>1</maxHistory>
</rollingPolicy>
</appender>
@@ -30,7 +30,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover and keep 7 days' worth of history -->
<fileNamePattern>info-%d{MM-dd-yyyy}.log</fileNamePattern>
<fileNamePattern>logs/info-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>1</maxHistory>
</rollingPolicy>
</appender>

View File

@@ -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

View File

@@ -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>