public final class COSString extends COSBase implements Encryptable
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.
| Constructor and Description |
|---|
COSString(byte[] bytes)
Creates a new PDF string from a byte array.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(COSVisitor visitor)
Visitor pattern for the COS model objects
|
boolean |
encryptable() |
void |
encryptable(boolean encryptable)
Sets if the object can be encrypted
|
boolean |
equals(Object obj) |
byte[] |
getBytes() |
String |
getString() |
int |
hashCode() |
boolean |
isForceHexForm() |
static COSString |
newInstance(byte[] value)
Factory method for a
COSString from a byte array |
static COSString |
parseHex(String hex)
Factory method creating a
COSString from a string of hex characters. |
static COSString |
parseLiteral(String literal)
Factory method creating a
COSString from a literal string. |
void |
setForceHexForm(boolean value)
Sets whether or not to force the string is to be written in hex form.
|
void |
setValue(byte[] value)
Sets the raw value of this string.
|
String |
toHexString() |
String |
toString() |
getCOSObject, hasId, id, idIfAbsentpublic COSString(byte[] bytes)
bytes - The raw bytes of the PDF text string or byte 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 isForceHexForm()
public String getString()
public byte[] getBytes()
public String toHexString()
public boolean encryptable()
encryptable in interface Encryptablepublic void encryptable(boolean encryptable)
Encryptableencryptable in interface Encryptablepublic void accept(COSVisitor visitor) throws IOException
COSBaseaccept in class COSBaseIOExceptionpublic static COSString newInstance(byte[] value)
COSString from a byte arrayvalue - public static COSString parseLiteral(String literal)
COSString from a literal string.literal - A literal string.COSString encoded with PDFDocEncoding encoding if possible, with
Charsets#UTF_16BE otherwise.IOException - If there is an error with the hex string.public static COSString parseHex(String hex) throws IOException
COSString from a string of hex characters.hex - A hex string.IOException - If there is an error with the hex string.Copyright © 2020 sejda. All rights reserved.