1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-15 10:46:26 +00:00

trim crappy characters

This commit is contained in:
Benjamin Gamard
2018-03-09 22:01:12 +01:00
parent f227335e14
commit 8b039c61ed
3 changed files with 18 additions and 15 deletions

View File

@@ -200,7 +200,7 @@ public class PdfUtil {
.addText("Created by " + documentDto.getCreator()
+ " on " + dateFormat.format(new Date(documentDto.getCreateTimestamp())), true)
.newLine()
.addText(Strings.nullToEmpty(documentDto.getDescription()).replaceAll("[\r\n]", ""))
.addText(documentDto.getDescription())
.newLine();
if (!Strings.isNullOrEmpty(documentDto.getSubject())) {
pdfPage.addText("Subject: " + documentDto.getSubject());

View File

@@ -1,13 +1,13 @@
package com.sismics.docs.core.util.pdf;
import java.io.Closeable;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDFont;
import java.io.Closeable;
import java.io.IOException;
/**
* Wrapper around PDFBox for high level abstraction of PDF writing.
*
@@ -102,7 +102,10 @@ public class PdfPage implements Closeable {
if (text == null) {
return;
}
// Remove \r\n non breakable space
text = text.replaceAll("[\r\n]", "").replace("\u00A0", " ");
pdContent.setFont(font, fontSize);
int start = 0;
int end = 0;