org.foray.pdf.object
Class PDFTextString

java.lang.Object
  extended by org.foray.pdf.object.PDFObject
      extended by org.foray.pdf.object.PDFTextString

public class PDFTextString
extends PDFObject

A PDF Text String, as defined in PDF Reference, 2nd Edition, Section 3.8.1. Text-strings are used in such PDF concepts as bookmarks, text annotations, etc., which do not have control over fonts, layout, etc. For string objects used in PDF content streams, see PDFString.

See Also:
PDFString

Field Summary
static char INVALID_PDF_DOC_ENCODING
          This char is returned when a Unicode character cannot be encoded using the PDFDocEncoding.
 
Fields inherited from class org.foray.pdf.object.PDFObject
EOL, MSG_EOL, XREF_EOL
 
Constructor Summary
PDFTextString(PDFDocument doc, CharSequence string)
          Constructor.
 
Method Summary
 boolean isEmpty()
          Indicates whether this String has any content.
 String toPDF()
          Generates the PDF text necessary to represent the object, returning it as a String.
static char unicodeToPDFDocEncoding(char unicodeChar)
          Converts a Unicode character to its PDFDocEncoding equivalent, if possible.
static String unicodeToPDFDocEncoding(CharSequence unicodeString)
          Converts a String from Unicode to PDFDocEncoding, if possible.
 
Methods inherited from class org.foray.pdf.object.PDFObject
bufferToByteArray, byteArrayToStream, getCharsPerLine, getGeneration, getLogger, getNumber, getPDFDocument, output, pdfID, pdfReference, setNumber, stringToByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_PDF_DOC_ENCODING

public static final char INVALID_PDF_DOC_ENCODING
This char is returned when a Unicode character cannot be encoded using the PDFDocEncoding.

See Also:
Constant Field Values
Constructor Detail

PDFTextString

public PDFTextString(PDFDocument doc,
                     CharSequence string)
Constructor.

Parameters:
doc - The parent PDF document.
string - The encapsulated String.
Method Detail

toPDF

public String toPDF()
Generates the PDF text necessary to represent the object, returning it as a String. Convert this.theString to valid content for a PDF String Object. See PDF Reference, 2nd edition, Section 3.2.3 for general information on String objects, including how to add non-ASCII characters. See Section 3.8.1 for information on the Unicode byte markers that must be present for Text Strings that are encoded in Unicode (as opposed to PDFDocEncoding).

Returns:
The PDF text necessary to represent the object.

unicodeToPDFDocEncoding

public static String unicodeToPDFDocEncoding(CharSequence unicodeString)
Converts a String from Unicode to PDFDocEncoding, if possible.

Parameters:
unicodeString - The String to be converted.
Returns:
The converted String, or null if unicodeString contains one or more chars that cannot be converted to PDFDocEncoding.

unicodeToPDFDocEncoding

public static char unicodeToPDFDocEncoding(char unicodeChar)
Converts a Unicode character to its PDFDocEncoding equivalent, if possible.

Parameters:
unicodeChar - The Unicode character to be converted.
Returns:
The PDFDocEncoding equivalent of #unicodeChar if possible, or #INVALID_PDF_DOC_ENCODING if it cannot be converted.

isEmpty

public boolean isEmpty()
Indicates whether this String has any content.

Returns:
True iff this String has no content.


Copyright © 2017. All rights reserved.