From 52fe4c6aa682d109c5a3c0021bd915b0a79515cf Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 10 Jan 2024 19:17:09 +0800 Subject: [PATCH 1/6] Specify code block language in Markdown for syntax highlighting --- FolderScanning.md | 2 +- HowToAddNewLanguage.md | 2 +- PipelineFeature.md | 2 +- README.md | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FolderScanning.md b/FolderScanning.md index 309b063c..6b743a7f 100644 --- a/FolderScanning.md +++ b/FolderScanning.md @@ -2,7 +2,7 @@ ### Whilst Pipelines are in alpha... You must enable this alpha functionality by setting -``` +```yaml system: enableAlphaFunctionality: true ``` diff --git a/HowToAddNewLanguage.md b/HowToAddNewLanguage.md index 4cdcedfe..1b218183 100644 --- a/HowToAddNewLanguage.md +++ b/HowToAddNewLanguage.md @@ -16,7 +16,7 @@ If your language isnt represented by a flag just find whichever closely matches For example to add Polish you would add -``` +```html icon Polski diff --git a/PipelineFeature.md b/PipelineFeature.md index c2c935b4..8d51c3c5 100644 --- a/PipelineFeature.md +++ b/PipelineFeature.md @@ -2,7 +2,7 @@ ## Whilst Pipelines are in alpha... You must enable this alpha functionality by setting -``` +```yaml system: enableAlphaFunctionality: true ``` diff --git a/README.md b/README.md index 4d79b6a3..00309036 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ For people that don't mind about space optimization just use the latest tag. ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest-ultra-lite?label=Stirling-PDF%20Ultra-Lite) Docker Run -``` +```bash docker run -d \ -p 8080:8080 \ -v /location/of/trainingData:/usr/share/tesseract-ocr/5/tessdata \ @@ -125,7 +125,7 @@ docker run -d \ -v /location/of/customFiles:/customFiles \ ``` Docker Compose -``` +```yaml version: '3.3' services: stirling-pdf: @@ -197,7 +197,7 @@ This file is located in the ``/configs`` directory and follows standard YAML for Environment variables are also supported and would override the settings file For example in the settings.yml you have -``` +```yaml system: defaultLocale: 'en-US' ``` @@ -205,7 +205,7 @@ system: To have this via an environment variable you would have ``SYSTEM_DEFAULTLOCALE`` The Current list of settings is -``` +```yaml security: enableLogin: false # set to 'true' to enable login csrfDisabled: true From 99050ad73e793d225ef97a2b98c0b25cd0385482 Mon Sep 17 00:00:00 2001 From: Stirling-PDF-Bot Date: Wed, 10 Jan 2024 12:56:05 +0000 Subject: [PATCH 2/6] Update 3rd Party Licenses --- src/main/resources/static/3rdPartyLicenses.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/static/3rdPartyLicenses.json b/src/main/resources/static/3rdPartyLicenses.json index 25e8e91b..88263b1d 100644 --- a/src/main/resources/static/3rdPartyLicenses.json +++ b/src/main/resources/static/3rdPartyLicenses.json @@ -356,22 +356,22 @@ }, { "moduleName": "org.apache.pdfbox:fontbox", - "moduleUrl": "http://pdfbox.apache.org/", - "moduleVersion": "2.0.29", + "moduleUrl": "https://pdfbox.apache.org", + "moduleVersion": "2.0.30", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "org.apache.pdfbox:pdfbox", - "moduleUrl": "http://pdfbox.apache.org", - "moduleVersion": "2.0.29", + "moduleUrl": "https://pdfbox.apache.org", + "moduleVersion": "2.0.30", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "org.apache.pdfbox:xmpbox", - "moduleUrl": "http://pdfbox.apache.org", - "moduleVersion": "2.0.29", + "moduleUrl": "https://pdfbox.apache.org", + "moduleVersion": "2.0.30", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0.txt" }, From ee223d040574367e253aac622b65c6c01c584d0d Mon Sep 17 00:00:00 2001 From: TieStone <416138794@qq.com> Date: Mon, 8 Jan 2024 19:38:47 +0800 Subject: [PATCH 3/6] add table support --- build.gradle | 1 + .../controller/api/converters/ConvertMarkdownToPdf.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 40dda97f..2f3dad04 100644 --- a/build.gradle +++ b/build.gradle @@ -152,6 +152,7 @@ dependencies { 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-ext-gfm-tables:0.17.2' // https://mvnrepository.com/artifact/com.github.vladimir-bukhtoyarov/bucket4j-core implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0' diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index d0fd632d..abfcb139 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -1,5 +1,9 @@ package stirling.software.SPDF.controller.api.converters; +import java.util.List; + +import org.commonmark.Extension; +import org.commonmark.ext.gfm.tables.TablesExtension; import org.commonmark.node.Node; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; @@ -47,9 +51,10 @@ public class ConvertMarkdownToPdf { } // Convert Markdown to HTML using CommonMark - Parser parser = Parser.builder().build(); + List extensions = List.of(TablesExtension.create()); + Parser parser = Parser.builder().extensions(extensions).build(); Node document = parser.parse(new String(fileInput.getBytes())); - HtmlRenderer renderer = HtmlRenderer.builder().build(); + HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build(); String htmlContent = renderer.render(document); byte[] pdfBytes = From ab9e7bbb8cbbd2f5dea44849c3d117cb40026f0d Mon Sep 17 00:00:00 2001 From: TieStone <416138794@qq.com> Date: Mon, 8 Jan 2024 20:29:42 +0800 Subject: [PATCH 4/6] add table support in md2pdf transport --- build.gradle | 2 +- .../api/converters/ConvertMarkdownToPdf.java | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2f3dad04..d9f62736 100644 --- a/build.gradle +++ b/build.gradle @@ -152,7 +152,7 @@ dependencies { 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-ext-gfm-tables:0.17.2' + implementation 'org.commonmark:commonmark-ext-gfm-tables:0.21.0' // https://mvnrepository.com/artifact/com.github.vladimir-bukhtoyarov/bucket4j-core implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0' diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index abfcb139..67b8fdd9 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -1,11 +1,14 @@ package stirling.software.SPDF.controller.api.converters; import java.util.List; +import java.util.Map; import org.commonmark.Extension; +import org.commonmark.ext.gfm.tables.TableBlock; import org.commonmark.ext.gfm.tables.TablesExtension; import org.commonmark.node.Node; import org.commonmark.parser.Parser; +import org.commonmark.renderer.html.AttributeProvider; import org.commonmark.renderer.html.HtmlRenderer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -53,9 +56,16 @@ public class ConvertMarkdownToPdf { // Convert Markdown to HTML using CommonMark List extensions = List.of(TablesExtension.create()); Parser parser = Parser.builder().extensions(extensions).build(); + Node document = parser.parse(new String(fileInput.getBytes())); - HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build(); + HtmlRenderer renderer = + HtmlRenderer.builder() + .attributeProviderFactory(context -> new TableAttributeProvider()) + .extensions(extensions) + .build(); + String htmlContent = renderer.render(document); + System.out.println(htmlContent); byte[] pdfBytes = FileToPdf.convertHtmlToPdf( @@ -67,3 +77,12 @@ public class ConvertMarkdownToPdf { return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename); } } + +class TableAttributeProvider implements AttributeProvider { + @Override + public void setAttributes(Node node, String tagName, Map attributes) { + if (node instanceof TableBlock) { + attributes.put("class", "table table-striped"); + } + } +} From 81d49b722bac2e223851407532083b21dfc600ac Mon Sep 17 00:00:00 2001 From: TieStone <416138794@qq.com> Date: Wed, 10 Jan 2024 21:29:43 +0800 Subject: [PATCH 5/6] add table support in md2pdf transport --- .../SPDF/controller/api/converters/ConvertMarkdownToPdf.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index 67b8fdd9..fe590459 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -65,7 +65,6 @@ public class ConvertMarkdownToPdf { .build(); String htmlContent = renderer.render(document); - System.out.println(htmlContent); byte[] pdfBytes = FileToPdf.convertHtmlToPdf( From 575e0b3e540916eb31d08347b9f693982102abcc Mon Sep 17 00:00:00 2001 From: Saud Fatayerji Date: Thu, 11 Jan 2024 22:07:56 +0300 Subject: [PATCH 6/6] Updated demo site --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d79b6a3..882cb9a2 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Please feel free to submit feature requests or report bugs either through GitHub For a overview of the tasks and the technology each uses please view [Endpoint-groups.md](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/Endpoint-groups.md) -Hosted instance/demo of the app can be seen [here](https://pdf.adminforge.de/) hosted by the team at adminforge.de +Demo of the app is available [here](https://stirlingpdf.io). username: demo, password: demo ## Technologies used - Spring Boot + Thymeleaf