From d6afb07533787f3ebeca4c85e21bad3a4d952153 Mon Sep 17 00:00:00 2001 From: Atrem Petrenko <64548375+Artem-ka-create@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:58:40 +0100 Subject: [PATCH 1/3] starting issue, implementing pdf-to-csv view --- build.gradle | 64 ++-- .../web/ConverterWebController.java | 8 + src/main/resources/messages_en_US.properties | 21 +- src/main/resources/static/images/pdf-csv.svg | 1 + .../templates/convert/pdf-to-csv.html | 29 ++ .../resources/templates/fragments/navbar.html | 322 +++++++++--------- src/main/resources/templates/home.html | 81 ++--- 7 files changed, 293 insertions(+), 233 deletions(-) create mode 100644 src/main/resources/static/images/pdf-csv.svg create mode 100644 src/main/resources/templates/convert/pdf-to-csv.html diff --git a/build.gradle b/build.gradle index d727205a..42298136 100644 --- a/build.gradle +++ b/build.gradle @@ -46,15 +46,15 @@ launch4j { outfile="Stirling-PDF.exe" headerType="console" jarTask = tasks.bootJar - + errTitle="Encountered error, Do you have Java 17?" - downloadUrl="https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.exe" + downloadUrl="https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.exe" variables=["BROWSER_OPEN=true"] jreMinVersion="17" - + mutexName="Stirling-PDF" windowTitle="Stirling-PDF" - + messagesStartupError="An error occurred while starting Stirling-PDF" //messagesJreNotFoundError="This application requires a Java Runtime Environment, Please download Java 17." messagesJreVersionError="You are running the wrong version of Java, Please download Java 17." @@ -63,46 +63,56 @@ launch4j { } dependencies { - implementation 'org.yaml:snakeyaml:2.1' - implementation 'org.springframework.boot:spring-boot-starter-web:3.1.2' - implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.1.2' - - if (System.getenv('DOCKER_ENABLE_SECURITY') != 'false') { + implementation 'org.yaml:snakeyaml:2.1' + implementation 'org.springframework.boot:spring-boot-starter-web:3.1.2' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.1.2' + + if (System.getenv('DOCKER_ENABLE_SECURITY') != 'false') { implementation 'org.springframework.boot:spring-boot-starter-security:3.1.2' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.1.2.RELEASE' implementation "org.springframework.boot:spring-boot-starter-data-jpa" - implementation "com.h2database:h2" + implementation "com.h2database:h2" } - - testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.4' - - - // https://mvnrepository.com/artifact/org.apache.pdfbox/jbig2-imageio - implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4' - implementation 'commons-io:commons-io:2.13.0' - + testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.4' + + + + // https://mvnrepository.com/artifact/org.apache.pdfbox/jbig2-imageio + implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4' + implementation 'commons-io:commons-io:2.13.0' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' - - //general PDF + + //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 'org.bouncycastle:bcprov-jdk15on:1.70' - implementation 'org.bouncycastle:bcpkix-jdk15on:1.70' + implementation 'org.bouncycastle:bcpkix-jdk15on:1.70' implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'io.micrometer:micrometer-core' implementation group: 'com.google.zxing', name: 'core', version: '3.5.2' // https://mvnrepository.com/artifact/org.commonmark/commonmark - implementation 'org.commonmark:commonmark:0.21.0' + implementation 'org.commonmark:commonmark:0.21.0' // https://mvnrepository.com/artifact/com.github.vladimir-bukhtoyarov/bucket4j-core - implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0' - + implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0' + developmentOnly("org.springframework.boot:spring-boot-devtools") - compileOnly 'org.projectlombok:lombok:1.18.28' - annotationProcessor 'org.projectlombok:lombok:1.18.28' + compileOnly 'org.projectlombok:lombok:1.18.28' + annotationProcessor 'org.projectlombok:lombok:1.18.28' + +//// https://mvnrepository.com/artifact/technology.tabula/tabula +// implementation group: 'technology.tabula', name: 'tabula', version: '1.0.5' + + +// implementation files('/Users/artempetrenko/Java/Stirling-PDF/tabula-1.0.5-jar-with-dependencies.jar') + implementation fileTree(include: ['tabula-1.0.5-jar-with-dependencies.jar'],dir: 'libs') } + task writeVersion { def propsFile = file('src/main/resources/version.properties') def props = new Properties() @@ -128,7 +138,7 @@ jar { attributes 'Implementation-Title': 'Stirling-PDF', 'Implementation-Version': project.version } - + } tasks.named('test') { diff --git a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java index 76e7be8f..3bad71c9 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java @@ -99,6 +99,14 @@ public class ConverterWebController { return modelAndView; } + @GetMapping("/pdf-to-csv") + @Hidden + public ModelAndView pdfToCSV() { + ModelAndView modelAndView = new ModelAndView("convert/pdf-to-csv"); + modelAndView.addObject("currentPage", "pdf-to-csv"); + return modelAndView; + } + @GetMapping("/pdf-to-pdfa") @Hidden diff --git a/src/main/resources/messages_en_US.properties b/src/main/resources/messages_en_US.properties index a15f9ab6..b82d0619 100644 --- a/src/main/resources/messages_en_US.properties +++ b/src/main/resources/messages_en_US.properties @@ -93,7 +93,6 @@ account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users account.userControlSettings=User Control Settings account.changeUsername=Change Username -account.changeUsername=Change Username account.password=Confirmation Password account.oldPassword=Old password account.newPassword=New Password @@ -334,7 +333,12 @@ showJS.tags=JS home.autoRedact.title=Auto Redact home.autoRedact.desc=Auto Redacts(Blacks out) text in a PDF based on input text -showJS.tags=JS +autoRedact.tags=JS + +home.tableExtraxt.title=Table Extraction +home.tableExtraxt.desc=Table Extraction from PDF to CSV +tableExtraxt.tags=CSV + ########################### # # @@ -563,7 +567,7 @@ ScannerImageSplit.selectText.8=Sets the minimum contour area threshold for a pho ScannerImageSplit.selectText.9=Border Size: ScannerImageSplit.selectText.10=Sets the size of the border added and removed to prevent white borders in the output (default: 1). - + #OCR ocr.title=OCR / Scan Cleanup ocr.header=Cleanup Scans / OCR (Optical Character Recognition) @@ -682,8 +686,8 @@ imageToPDF.selectText.2=Auto rotate PDF imageToPDF.selectText.3=Multi file logic (Only enabled if working with multiple images) imageToPDF.selectText.4=Merge into single PDF imageToPDF.selectText.5=Convert to separate PDFs - - + + #pdfToImage pdfToImage.title=PDF to Image pdfToImage.header=PDF to Image @@ -773,7 +777,6 @@ changeMetadata.keywords=Keywords: changeMetadata.modDate=Modification Date (yyyy/MM/dd HH:mm:ss): changeMetadata.producer=Producer: changeMetadata.subject=Subject: -changeMetadata.title=Title: changeMetadata.trapped=Trapped: changeMetadata.selectText.4=Other Metadata: changeMetadata.selectText.5=Add Custom Metadata Entry @@ -823,3 +826,9 @@ PDFToXML.title=PDF to XML PDFToXML.header=PDF to XML PDFToXML.credit=This service uses LibreOffice for file conversion. PDFToXML.submit=Convert + +#PDFToCSV +PDFToCSV.title=PDF to CSV +PDFToCSV.header=PDF to CSV +PDFToCSV.credit=This service uses LibreOffice for file conversion. +PDFToCSV.submit=Convert diff --git a/src/main/resources/static/images/pdf-csv.svg b/src/main/resources/static/images/pdf-csv.svg new file mode 100644 index 00000000..95d68c10 --- /dev/null +++ b/src/main/resources/static/images/pdf-csv.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/convert/pdf-to-csv.html b/src/main/resources/templates/convert/pdf-to-csv.html new file mode 100644 index 00000000..bad849fb --- /dev/null +++ b/src/main/resources/templates/convert/pdf-to-csv.html @@ -0,0 +1,29 @@ + + + + + + +
+
+
+

+
+
+
+

+
+
+
+ + +
+

+
+
+
+
+
+
+ + diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index 4326afcc..5299c9b3 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -1,13 +1,13 @@
- + - - + + - +
- + - + + + + + @@ -147,23 +149,23 @@ - - - - + - - - + @@ -251,61 +253,61 @@ -
+