diff options
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java index 530964c..45afaf7 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java @@ -19,6 +19,8 @@ package at.knowcenter.wag.egov.egiz.pdf; import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+
/**
* Class that helps filling out the placeholders.
@@ -110,15 +112,30 @@ public class SplitStrings */
public void write(byte[] data)
{
+ data = tryProcessNewline(data);
if (!fits(data))
{
throw new IllegalArgumentException("The data doesn't fit in.");
}
- System.arraycopy(data, 0, pdf, this.strings[this.cur_string].string_start + this.cur_pos, data.length);
+ System.arraycopy(data, 0, this.pdf, this.strings[this.cur_string].string_start + this.cur_pos, data.length);
this.cur_pos += data.length;
}
+
+ /**
+ * Process starting \n token if found
+ * @param data
+ * @return
+ */
+ private byte[] tryProcessNewline(byte[] data) {
+ if (data.length > 0 && data[0] == '\n') {
+ // new line token \n found
+ newline();
+ data = ArrayUtils.subarray(data, 1, data.length);
+ }
+ return data;
+ }
/**
* Fills the current string with the fill character and moves on to the next
|