From 2af992106a61df9d13d9d57fd98079715b0aeafa Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Mon, 25 Jul 2016 11:28:13 +0200 Subject: Fixed wrong line calculation for wrapping forced newline character --- .../java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pdf-as-pdfbox/src/main/java/at/gv/egiz') diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java index 82d21b0f..234cf7a2 100644 --- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java +++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java @@ -386,7 +386,7 @@ public class PDFBoxTable { for (int i = 0; i < words.length; i++) { String word = words[i]; String[] lineBreaks = word.split("\n"); - if (lineBreaks.length > 1) { + if (lineBreaks.length > 1 || word.contains("\n")) { for (int j = 0; j < lineBreaks.length; j++) { String subword = lineBreaks[j]; // if (cLine + subword.length() > maxline) { @@ -407,6 +407,10 @@ public class PDFBoxTable { } cLineValue += subword + " "; } + if(lineBreaks.length == 1) { + lines.add(cLineValue.trim()); + cLineValue = ""; + } } else { String tmpLine = cLineValue + word; float size = font.getStringWidth(tmpLine) / 1000.0f * fontSize; -- cgit v1.2.3