From 09341ba86d33b02633e9ad2c2232c586cc671011 Mon Sep 17 00:00:00 2001 From: ferbas Date: Tue, 12 Jan 2010 09:33:05 +0000 Subject: fixed linebreak problem git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@543 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/pdf/Placeholder.java | 10 ++++++++-- .../knowcenter/wag/egov/egiz/pdf/SplitStrings.java | 20 ++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java index 9155f15..fce5dea 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.sound.midi.SysexMessage; + import org.apache.commons.codec.net.URLCodec; import org.apache.log4j.Logger; @@ -352,7 +354,7 @@ public abstract class Placeholder */ protected static boolean canBreakAfter(byte character) { - return (character == ' ' || character == ',' || character == ';' || character == '-'); + return (character == ' ' || character == ',' || character == ';' || character == '-' || character == '\n') ; } /** @@ -532,6 +534,7 @@ public abstract class Placeholder { byte data = bytes[index]; + // byte [] escaped_data = escapeByte(data); baos.write(data); @@ -541,10 +544,13 @@ public abstract class Placeholder } } + System.err.println("token: " + baos.toString()); return baos.toByteArray(); } - protected static byte[] escapeToken(byte[] token) throws IOException + + +protected static byte[] escapeToken(byte[] token) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); 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 45afaf7..b407b61 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 @@ -112,29 +112,17 @@ 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, 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; + + if (data[data.length-1] == '\n') { + newline(); + } } /** -- cgit v1.2.3