public final class COSString extends COSBase
Text strings are used for character strings that contain information intended to be human-readable, such as text annotations, bookmark names, article names, document information, and so forth.
PDFDocEncoded strings are used for characters that are represented in a single byte.
ASCII strings are used for characters that are represented in a single byte using ASCII encoding.
Byte strings are used for binary data represented as a series of bytes, but the encoding is not known. The bytes of the string need not represent characters.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
FORCE_PARSING |
| Constructor and Description |
|---|
COSString(byte[] bytes)
Creates a new PDF string from a byte array.
|
COSString(String text)
Creates a new text string from a Java String.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
accept(ICOSVisitor visitor)
Visitor pattern double dispatch method.
|
boolean |
equals(Object obj) |
String |
getASCII()
Returns the content of this string as a PDF ASCII string.
|
byte[] |
getBytes()
Returns the raw bytes of the string.
|
boolean |
getForceHexForm()
Returns true if the string is to be written in hex form.
|
Long |
getHexCount() |
String |
getString()
Returns the content of this string as a PDF text string.
|
int |
hashCode() |
boolean |
isContainsOnlyHex() |
boolean |
isHex() |
static COSString |
parseHex(String hex)
This will create a COS string from a string of hex characters.
|
void |
setContainsOnlyHex(boolean isHexSymbols) |
void |
setForceHexForm(boolean value)
Sets whether or not to force the string is to be written in hex form.
|
void |
setHexCount(Long hexCount) |
void |
setValue(byte[] value)
Sets the raw value of this string.
|
String |
toHexString()
This will take this string and create a hex representation of the bytes that make the string.
|
String |
toString() |
public COSString(byte[] bytes)
bytes - The raw bytes of the PDF text string or byte string.public COSString(String text)
text - The string value of the object.public boolean isHex()
public boolean isContainsOnlyHex()
public void setContainsOnlyHex(boolean isHexSymbols)
public Long getHexCount()
public void setHexCount(Long hexCount)
public static COSString parseHex(String hex) throws IOException
hex - A hex string.IOException - If there is an error with the hex string.public void setValue(byte[] value)
value - The raw bytes of the PDF text string or byte string.public void setForceHexForm(boolean value)
value - True to force hex.public boolean getForceHexForm()
public String getString()
public String getASCII()
public byte[] getBytes()
public String toHexString()
public Object accept(ICOSVisitor visitor) throws IOException
accept in class COSBasevisitor - The object to notify when visiting this object.IOException - If an error occurs while visiting this object.Copyright © 2015–2019 The veraPDF Consortium. All rights reserved.