aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorChristian Maierhofer <cmaierhofer@iaik.tugraz.at>2016-06-21 15:35:47 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-08-17 16:49:55 +0200
commit998859c70f4ce4e1ea6924b053c231351dfe5703 (patch)
treeeb85e2ab7b6f0eb0350d1f8d4a110cd80293ee7d /pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas
parent464c44c367f32f8e7624a6b3ed3474c95a69d6fa (diff)
downloadpdf-as-4-998859c70f4ce4e1ea6924b053c231351dfe5703.tar.gz
pdf-as-4-998859c70f4ce4e1ea6924b053c231351dfe5703.tar.bz2
pdf-as-4-998859c70f4ce4e1ea6924b053c231351dfe5703.zip
nbspace was not recognized by pdfbox' internal fonts
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java
index 415e1665..e35e3994 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java
@@ -49,6 +49,8 @@ public class PDFBoxTable {
private static final Logger logger = LoggerFactory
.getLogger(PDFBoxTable.class);
+
+ private static final String NBSPACE = '\u00A0'+"";
Table table;
Style style;
@@ -331,17 +333,19 @@ public class PDFBoxTable {
string = "";
cell.setValue(string);
}
- if (string.contains("\n")) {
+ if (string.contains(NBSPACE) || string.contains("\n")) {
float maxWidth = 0;
+ string = string.replace(NBSPACE, " ");
String[] lines = string.split("\n");
+
for (int i = 0; i < lines.length; i++) {
float w = c.getStringWidth(lines[i]) / 1000 * fontSize;
if (maxWidth < w) {
maxWidth = w;
}
}
- return maxWidth;
- } else {
+ }
+ else{
return c.getStringWidth(string) / 1000 * fontSize;
}
case Entry.TYPE_IMAGE:
@@ -399,6 +403,8 @@ public class PDFBoxTable {
}
// }
String tmpLine = cLineValue + subword;
+ tmpLine = tmpLine.replace(NBSPACE, " ");
+
float size = font.getStringWidth(tmpLine) / 1000.0f
* fontSize;
if (size > maxwidth && cLineValue.length() != 0) {
@@ -409,6 +415,8 @@ public class PDFBoxTable {
}
} else {
String tmpLine = cLineValue + word;
+ tmpLine = tmpLine.replace(NBSPACE, " ");
+
float size = font.getStringWidth(tmpLine) / 1000.0f * fontSize;
if (size > maxwidth && cLineValue.length() != 0) {
lines.add(cLineValue.trim());
@@ -418,6 +426,9 @@ public class PDFBoxTable {
}
}
lines.add(cLineValue.trim());
+ for(int i=0;i<lines.size();i++){
+ lines.set(i, lines.get(i).replace(NBSPACE, " "));
+ }
return lines.toArray(new String[0]);
}