diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/java/org/eclipse/sw360/antenna/workflow/generators/pdf/BasicPDFTemplateBundle.java b/modules/attribution-document/attribution-document-basic-bundle/src/main/java/org/eclipse/sw360/antenna/workflow/generators/pdf/BasicPDFTemplateBundle.java index 5e1a7109b..5a4ee7228 100644 --- a/modules/attribution-document/attribution-document-basic-bundle/src/main/java/org/eclipse/sw360/antenna/workflow/generators/pdf/BasicPDFTemplateBundle.java +++ b/modules/attribution-document/attribution-document-basic-bundle/src/main/java/org/eclipse/sw360/antenna/workflow/generators/pdf/BasicPDFTemplateBundle.java @@ -10,16 +10,24 @@ */ package org.eclipse.sw360.antenna.workflow.generators.pdf; +import org.apache.commons.io.IOUtils; import org.eclipse.sw360.antenna.attribution.document.core.TemplateBundle; -import java.io.InputStream; +import java.io.*; import java.util.Objects; +import java.util.Optional; public class BasicPDFTemplateBundle implements TemplateBundle { private static final String TITLE_TEMPLATE = "/templates/basic_title.pdf"; private static final String COPYRIGHT_TEMPLATE = "/templates/basic_copyright.pdf"; private static final String CONTENT_TEMPLATE = "/templates/basic_content.pdf"; private static final String BACKPAGE_TEMPLATE = "/templates/basic_back.pdf"; + private static final String SANS_FONT = "/templates/NotoSans-Regular.ttf"; + private static final String SANS_BOLD_FONT = "/templates/NotoSans-Bold.ttf"; + private static final String SANS_BOLD_ITALIC_FONT = "/templates/NotoSans-BoldItalic.ttf"; + private static final String SANS_ITALIC_FONT = "/templates/NotoSans-Italic.ttf"; + + @Override public String key() { @@ -46,6 +54,26 @@ public InputStream loadBackPageTemplate() { return loadFromClassPath(BACKPAGE_TEMPLATE); } + @Override + public Optional loadSansFont() { + return Optional.of(loadFromClassPath(SANS_FONT)); + } + + @Override + public Optional loadSansBoldFont() { + return Optional.of(loadFromClassPath(SANS_BOLD_FONT)); + } + + @Override + public Optional loadSansBoldItalicFont() { + return Optional.of(loadFromClassPath(SANS_BOLD_ITALIC_FONT)); + } + + @Override + public Optional loadSansItalicFont() { + return Optional.of(loadFromClassPath(SANS_ITALIC_FONT)); + } + private InputStream loadFromClassPath(String resource) { InputStream resourceAsStream = BasicPDFTemplateBundle.class.getResourceAsStream(resource); Objects.requireNonNull(resourceAsStream, "Unable to load resource for '" + resource + diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/.~lock.basic-pdf-template.odt# b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/.~lock.basic-pdf-template.odt# new file mode 100644 index 000000000..a6d7a76b4 --- /dev/null +++ b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/.~lock.basic-pdf-template.odt# @@ -0,0 +1 @@ +,DESKTOP-SQSHFMF/Anwender,DESKTOP-SQSHFMF,30.06.2020 01:10,file:///C:/Users/Anwender/AppData/Roaming/OpenOffice/4; \ No newline at end of file diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Bold.ttf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Bold.ttf new file mode 100644 index 000000000..1db7886e9 Binary files /dev/null and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Bold.ttf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-BoldItalic.ttf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-BoldItalic.ttf new file mode 100644 index 000000000..385e6acb7 Binary files /dev/null and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-BoldItalic.ttf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Italic.ttf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Italic.ttf new file mode 100644 index 000000000..6d2c71c86 Binary files /dev/null and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Italic.ttf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Regular.ttf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Regular.ttf new file mode 100644 index 000000000..0a01a062f Binary files /dev/null and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/NotoSans-Regular.ttf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic-pdf-template.odt b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic-pdf-template.odt index fec239925..865123ab9 100644 Binary files a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic-pdf-template.odt and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic-pdf-template.odt differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_back.pdf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_back.pdf index a932d2bad..8d5e85ea8 100644 Binary files a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_back.pdf and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_back.pdf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_content.pdf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_content.pdf index 2e51fa6fd..61a3398af 100644 Binary files a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_content.pdf and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_content.pdf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_copyright.pdf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_copyright.pdf index 7b2ded3bf..be9802b43 100644 Binary files a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_copyright.pdf and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_copyright.pdf differ diff --git a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_title.pdf b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_title.pdf index 7c89074d1..ddc03902c 100644 Binary files a/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_title.pdf and b/modules/attribution-document/attribution-document-basic-bundle/src/main/resources/templates/basic_title.pdf differ diff --git a/modules/attribution-document/attribution-document-core/src/main/java/org/eclipse/sw360/antenna/attribution/document/core/AttributionDocumentGeneratorImpl.java b/modules/attribution-document/attribution-document-core/src/main/java/org/eclipse/sw360/antenna/attribution/document/core/AttributionDocumentGeneratorImpl.java index f3afee8c6..6a5aab0c9 100644 --- a/modules/attribution-document/attribution-document-core/src/main/java/org/eclipse/sw360/antenna/attribution/document/core/AttributionDocumentGeneratorImpl.java +++ b/modules/attribution-document/attribution-document-core/src/main/java/org/eclipse/sw360/antenna/attribution/document/core/AttributionDocumentGeneratorImpl.java @@ -27,6 +27,7 @@ import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode; import org.apache.pdfbox.pdmodel.font.PDFont; +import org.apache.pdfbox.pdmodel.interactive.annotation.layout.PlainText; import org.eclipse.sw360.antenna.api.exceptions.ExecutionException; import org.eclipse.sw360.antenna.attribution.document.core.model.ArtifactAndLicense; import org.eclipse.sw360.antenna.attribution.document.core.model.LicenseInfo; @@ -177,8 +178,22 @@ private Document writeLicenseText(Document document, List ar boldFont, italicFont, boldItalicFont); - p.addText(license.getText(), 10, sansFont); - + List lines = Arrays.asList(license + .getText() + .replace("\u0009", " ") + .replace("\u0092", "") + .replace("\u009d", "") + .replace("\u221e", "(infinity)") + .replace("\u2212", "-") + .replace("\u25aa", "[]") + .replace("\u2661", "(heart)") + .replace("\udbff", "") + .replace("\udc00", "") + .replace("\uf0b7", "") + .split("\\r\\n|\\n|\\r|\\u2028|\\u2029")); + for (String line : lines) { + p.addText(line, 10, sansFont); + } document.add(p); }