DynaPDF Manual - Page 645
Previous Page 644 Index Next Page 646

Function Reference
Page 645 of 874
TSetFont
The TSetFont callback function activates a font in the graphics state. The following variables of the
graphics state must be set when the callback function is executed:
m_GState.ActiveFont = Font;
m_GState.FontSize
= FontSize;
m_GState.FontType
= Type;
m_GState.SpaceWidth = (float)(fntGetSpaceWidth(Font, FontSize) * 0.5);
The space width is required to construct text lines. It is usually best to use the half space width to
determine whether a space must be inserted at a specific position because many PDF fonts do not
contain a space character and the function fntGetSpaceWidth() returns just a default width in this
case (the function name is GetSpaceWidth() in C#, Delphi, and VB .Net).
The space width is measured in text space like the member Advance of a kerning record. However,
the distance between two text records is measured in user space! So, the space width must be
transformed to user space before it can be compared with the distance between two text records. See
the description of the TShowTextArrayW callback function for further information.
TRestoreGraphicState
As the name of the function suggests the graphics state must be restored when the callback function
is executed. The graphics state stack is a LIFO (last in first out) data structure that stores copies of
the graphics state. The last element from the graphics state stack must be popped and the values
must be copied to the current graphics state.
It is guaranteed that this function is not executed without a preceeding TSaveGraphicState call.
Invalid restore graphics state operators are trated as an error. The parser breaks processing when it
encounters such an error.
The return value of the function must be zero. Any other return value breaks processing.
TSaveGraphicState
As the name suggests the current graphics state must be saved when the callback function is
executed. As already described at TRestoreGraphiState the graphics state stack is a LIFO (last in first
out) data structure that stores copies of the graphics state. The application must create a copy of the
current graphics state and push it onto the graphics state stack.
It is not guaranteed that all saved graphics states will be restored until the page was fully parsed.
The application must make sure that remaining copies of the graphics state will be released before
parsing the next page or terminating the application.
The return value of the function must be zero. Any other return value breaks processing.
TShowTextArrayA
This is the preferred callback function to develop text search algorithms. See also Sub string
coordinates for further information. The function returns the source strings which can be converted
Previous topic: Inside the Callback Functions, TBeginTemplate, TMulMatrix
Next topic: TShowTextArrayW