Skip to content

Commit

Permalink
Replaces unavailable characters for the AttributionDocumentGenerator
Browse files Browse the repository at this point in the history
The AttributionDocumentGenerator cannot handle unicodes like tabs
(U+0009) and newlines (U+2028, U+2029) for layour purposes. Therefore it
will be replaced manually. In addition, some unavailable unicodes are
also replaced.

Resolves eclipse-archived#548.

Signed-off-by: Onur Demirci <[email protected]>
  • Loading branch information
bs-ondem committed Jun 30, 2020
1 parent acbfb77 commit a7b5d53
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -177,8 +178,22 @@ private Document writeLicenseText(Document document, List<ArtifactAndLicense> ar
boldFont,
italicFont,
boldItalicFont);
p.addText(license.getText(), 10, sansFont);

List<String> 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);
}

Expand Down

0 comments on commit a7b5d53

Please sign in to comment.