DynaPDF Manual - Page 652
Previous Page 651 Index Next Page 653

Function Reference
Page 652 of 883
TextDrawMode
TDrawMode
dmNormal
TextScale
float
100.0f
WordSpacing
float
0.0f
The text color is normally not required when extracting text. If it should be considered the current
fill and stroke color must be available in the graphics state and the corresponding callback functions
must be set. Whether the current fill or stroke color must be used as text color depends on the text
draw mode (see also SetTextDrawMode()).
Note that colors in PDF are represented by an array of double where each component ranges from
0.0 through 1.0 of the corresponding color space. However, colors are normally processed in a
unique device color space such as DevicedGray, DeviceRGB, or DeviceCMYK because applications
which use the content parser have normally no build-in support for PDF color spaces. Colors which
are set by the TSetFillColor and TSetStrokeColor callback functions should be converted to a device
color space with ConvColor(). The resulting device color must then be stored in the graphics state.
The TEndTemplate callback function is optional because no specific operation is required to be
executed when a template is leaved.
Unicode conversion
The extraction of human readable text requires a conversion to a well known encoding like Unicode
because PDF strings are not necessarily human readable.
Whether it is possible to convert a PDF string to Unicode depends on whether the required
encoding information is available. This is always the case if a font uses a predefined encoding like
WinAnsi or MacRoman or if the glyph names of Type1 fonts are available in the Adobe Glyph List
or ZapfDingbats encoding.
Fonts which use a symbol encoding can provide a ToUnicode CMap which offers the required
mapping to Unicode. However, this CMap is optional and is not necessarily available. If a symbol
font does not contain a ToUnicode CMap the strings are converted to the code page 1252.
External CMaps
A widely used technique to reduce the amount of data that must stored in a PDF file is the usage of
non embedded CID fonts. CID fonts, whether embedded or not, can depend on external CMap files
which offer the required mapping to Unicode.
To process strings of such fonts correctly, DynaPDF must be able to load required CMap files if
necessary. Therefore, DynaPDF is delivered with the most important CMap files which are provided
by Adobe Systems. These CMaps can be found in the DynaPDF installation directory at
/Resource/CMap/. Applications which extract text from PDF files should include these CMaps so
that they can be loaded at runtime.
The search path to external CMaps must be set with SetCMapDir() before executing ParseContent()
the first time. The function creates a CMap cache that is hold in memory until the PDF instance will
be deleted. The search path(s) to external CMap files should be set only one time per PDF instance
Previous topic: Using the Content Parser, Text Extraction or Text Search Algorithms
Next topic: Inside the Callback Functions, TBeginTemplate, TMulMatrix