DynaPDF Manual - Page 815

Previous Page 814   Index   Next Page 816

Function Reference
Page 815 of 839
The parameter Decoded is set to true if the source character could be sucsessfully converted to
Unicode. If Decode is false the output string and character width contain no meaningful values.
The function can only fail when processing strings of CID fonts, e.g. if the font depends on an
external CMap that could not be loaded, or if the font uses a damaged CMap. The search path(s) to
external CMaps should always be set before extracting text from PDF files with SetCMapDir().
Passing an invalid or undefined code sequence to the function does not result in an error. In this
case the notdef character is added to the output string (this is usually 0 or 0xFFFD if the font
contains a ToUnicode CMap).
To improve processing speed the function does not check whether the parameters are valid.
This function was designed to convert raw strings on a per character basis to Unicode which were
returned by ParseContent() or GetPageText(). The parameters CharSpacing, WordSpacing, and
TextScale must be taken from the current graphics state or from the structure TPDFStack.
Return values:
The return value of this function is always greater or equal to one. Check the parameter Decoded to
determine whether the function succeed.
TranslateString (obsolete)
SI32 fntTranslateString(
struct TPDFStack* Stack, // Structure which holds the current text
UI16* OutText,
// Output Unicode buffer
UI32 Size,
// Length of the Unicode buffer in characters
UI32 Flags)
// No flags are defined at this time
The function converts a binary string to Unicode that was returned by GetPageText(). This function
is marked as obsolete because the member Kerning of the structure TPDFStack contains already the
converted Unicode string. See GetPageText() for further information.
The converted string is copied to the parameter OutText. The output buffer must be allocated by the
caller. Note that the string buffer is a Unicode string in UTF-16 format. The parameter Size
represents the length of the buffer in characters, it must be long enough to hold the entire string.
The output buffer should be at least stack.TextLen * 16 / 10 + 32 characters long. However, to avoid
unnecessary memory allocation calls it is usually best to use a static conversion buffer with a length
of about 2048 or 4096 characters. Longer strings can normally not occur in well formatted PDF files
because a huge paper format would be required to display such a long string.

Previous topic: TranslateCoords, TranslateRawCode (Font API)

Next topic: TranslateString2 (Font API)