From cdb89970ab42b4477e06ae7b59f2a5bf9f3d1bdc Mon Sep 17 00:00:00 2001 From: ferbas Date: Tue, 5 Jan 2010 14:43:42 +0000 Subject: added newline \n support git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@536 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/at') 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 -- cgit v1.2.3