Merge branch 'contributing' of https://github.com/Stirling-Tools/Stirling-PDF into contributing
This commit is contained in:
commit
b6523e9989
7 changed files with 40 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
### Whilst Pipelines are in alpha...
|
||||
You must enable this alpha functionality by setting
|
||||
```
|
||||
```yaml
|
||||
system:
|
||||
enableAlphaFunctionality: true
|
||||
```
|
||||
|
|
|
@ -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
|
||||
<a class="dropdown-item lang_dropdown-item" href="" data-language-code="pl_PL">
|
||||
<img src="images/flags/pl.svg" alt="icon" width="20" height="15"> Polski
|
||||
</a>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Whilst Pipelines are in alpha...
|
||||
You must enable this alpha functionality by setting
|
||||
```
|
||||
```yaml
|
||||
system:
|
||||
enableAlphaFunctionality: true
|
||||
```
|
||||
|
|
10
README.md
10
README.md
|
@ -79,7 +79,7 @@ All files and PDFs exist either exclusively on the client side, reside in server
|
|||
|
||||
|
||||
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
|
||||
|
@ -107,7 +107,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 \
|
||||
|
@ -123,7 +123,7 @@ docker run -d \
|
|||
-v /location/of/customFiles:/customFiles \
|
||||
```
|
||||
Docker Compose
|
||||
```
|
||||
```yaml
|
||||
version: '3.3'
|
||||
services:
|
||||
stirling-pdf:
|
||||
|
@ -190,7 +190,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'
|
||||
```
|
||||
|
@ -198,7 +198,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
|
||||
|
|
|
@ -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.21.0'
|
||||
// https://mvnrepository.com/artifact/com.github.vladimir-bukhtoyarov/bucket4j-core
|
||||
implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0'
|
||||
|
||||
|
|
|
@ -1,7 +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;
|
||||
|
@ -47,9 +54,16 @@ public class ConvertMarkdownToPdf {
|
|||
}
|
||||
|
||||
// Convert Markdown to HTML using CommonMark
|
||||
Parser parser = Parser.builder().build();
|
||||
List<Extension> 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()
|
||||
.attributeProviderFactory(context -> new TableAttributeProvider())
|
||||
.extensions(extensions)
|
||||
.build();
|
||||
|
||||
String htmlContent = renderer.render(document);
|
||||
|
||||
byte[] pdfBytes =
|
||||
|
@ -62,3 +76,12 @@ public class ConvertMarkdownToPdf {
|
|||
return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename);
|
||||
}
|
||||
}
|
||||
|
||||
class TableAttributeProvider implements AttributeProvider {
|
||||
@Override
|
||||
public void setAttributes(Node node, String tagName, Map<String, String> attributes) {
|
||||
if (node instanceof TableBlock) {
|
||||
attributes.put("class", "table table-striped");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue