aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag
diff options
context:
space:
mode:
authorferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-05 14:43:42 +0000
committerferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-05 14:43:42 +0000
commitcdb89970ab42b4477e06ae7b59f2a5bf9f3d1bdc (patch)
treef1acdf64454b88516a7e9ac843c6d6cf81162042 /src/main/java/at/knowcenter/wag
parentf2ab6263e22b06f9aee4caeb2f5ebadf8dc5076c (diff)
downloadpdf-as-3-cdb89970ab42b4477e06ae7b59f2a5bf9f3d1bdc.tar.gz
pdf-as-3-cdb89970ab42b4477e06ae7b59f2a5bf9f3d1bdc.tar.bz2
pdf-as-3-cdb89970ab42b4477e06ae7b59f2a5bf9f3d1bdc.zip
added newline \n support
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@536 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/SplitStrings.java19
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