|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.knowcenter.wag.egov.egiz.pdf.Placeholder
public abstract class Placeholder
Helper class that provides functionality for dealing with placeholders and replacements in pdf.
Constructor Summary | |
---|---|
Placeholder()
|
Method Summary | |
---|---|
static byte[] |
applyURLEncoding(String text)
Applies the URL encoding to the text. |
static byte[] |
applyWinAnsiEncoding(String text)
Prepares the given String to a byte array that can be substituted into the placeholder. |
protected static boolean |
canBreakAfter(byte character)
Tells, if a break can occur behind the given character. |
static byte[] |
escapeByte(byte data)
Escapes the data byte if necessary. |
static byte[] |
escapePDFString(byte[] data)
Escapes the String to be a suitable Literal String.. |
protected static byte[] |
escapeToken(byte[] token)
|
protected static boolean |
isURLEncoded(String text)
Checks the presence of typical URL encoded characters to tell if the string is URL encoded. |
static List |
parseStrings(byte[] pdf,
int stream_start,
int stream_next)
Scans the given PDF content stream for literal PDF strings. |
protected static byte[] |
readToken(byte[] bytes,
int index)
|
static String |
reconstructStringFromPartition(byte[] pdf,
List sis,
byte[] enc)
Reconstructs the string from a partition of placeholders. |
static void |
replacePlaceholderWithTolerance(byte[] pdf,
List sis,
byte[] replace_bytes,
int tolerance)
Replaces the placeholder with the given String breaking lines with a given tolerance. |
static String |
unapplyURLEncoding(String winansi_str)
Unapplies the WinAnsi and URL encoding. |
static String |
unapplyWinAnsiEncoding(byte[] replace_bytes)
Unapplies the WinAnsi encoding. |
static byte[] |
unescapePDFString(byte[] data)
Unescapes the PDF String. |
static String |
unprepareAndUnescapeString(byte[] pdf_string)
Restores the String from a previously prepared byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Placeholder()
Method Detail |
---|
public static byte[] escapePDFString(byte[] data)
data
- The String to be escaped.
public static byte[] unescapePDFString(byte[] data)
data
- The escaped String.
public static String reconstructStringFromPartition(byte[] pdf, List sis, byte[] enc) throws IOException
pdf
- The PDF to read the string from.sis
- The list of StringInfo objects that specify the bytes of the
string in the pdf.
IOException
- Forwarded exception.public static byte[] applyWinAnsiEncoding(String text)
text
- The text to be prepared for substitution.
public static String unapplyWinAnsiEncoding(byte[] replace_bytes)
replace_bytes
- The bytes.
public static byte[] applyURLEncoding(String text)
text
- The text
public static String unapplyURLEncoding(String winansi_str)
winansi_str
- The Winansi and URL text.
public static String unprepareAndUnescapeString(byte[] pdf_string)
pdf_string
- The byte array.
protected static boolean isURLEncoded(String text)
This heuristic checks if there are any non URL encoded characters in the String, like ASCII control characters, which aren't allowed in the URLEncoding characterset.
text
- The text under suspicion.
protected static boolean canBreakAfter(byte character)
character
- The character.
public static List parseStrings(byte[] pdf, int stream_start, int stream_next)
pdf
- The PDF.stream_start
- The start of the content stream to be scanned.stream_next
- The end of the content stream.
public static byte[] escapeByte(byte data)
Before bytes can be written into the pdf Strings, they have to be escaped. Special care has to be taken that escaped sequences are not split due to line breaks. This could have fatal consequences and usually renders the whole document invalid.
data
- The data byte to be escaped.
public static void replacePlaceholderWithTolerance(byte[] pdf, List sis, byte[] replace_bytes, int tolerance) throws PDFDocumentException
pdf
- The PDF.sis
- The list of StringInfo objects describing the positions where the
String should be filled in.replace_bytes
- The unescaped bytes to be filled in. Escaping is performed by this
method.tolerance
- The tolerance for line wrapping. The tolerance counts from the end
of a StringInfo backwards to its start. If a word that starts
within the tolerance doesn't fit, it is wrapped into the next
line.
PDFDocumentException
- Forwarded exception.protected static byte[] readToken(byte[] bytes, int index)
protected static byte[] escapeToken(byte[] token) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |