DynaPDF Manual - Page 62
Previous Page 61 Index Next Page 63
Content parsing & editing
Page 62 of 860
The page that should be parsed should be closed, that means it should not be opened for editing
beforehand with EditPage() or Append(). The function can parse an open page too but this can
lead to errors and is not recommended.
At time of publication only the minimal functionality is documented but more and more
examples and documentation will be added.
The parameters UserData and Funcs are currently available in C/C++ only. The callback API can
be used for immediate mode. That means the callback functions are executed immediatly when
a corresponding operator was found. This is comparable with ParseContent() but not identically
because the C object structure is still build so that the page contents can be modified.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
ReplaceSelText
Syntax:
LBOOL psrReplaceSelText(
const PPDF* IPDF,
// PDF instance pointer
const IPSR* Ctx,
// Parser instance pointer
TReplaceTextFlags Flags,
// See below
struct TTextSelection* SelText, // Required -> output of FindText()
const UI16* Text,
// Optional replacment text
UI32 TextLen)
// Length in characters
The function replaces or deletes the text that was found by FindText(). Coordinates of
surrounding text are not changed, this means that the new text can overlap surrounding text if
the width of the new text is larger than the original text.
So, text replacement has its limitations since at some point text must might be new formatted or
re-aligned. However, replacing placeholders with text is usually no problem as long as there is
enough room for the new text.
Note that placeholders should not contain space characters since spaces are often not stored in
PDF files and this can lead to issues finding the text.
Font substitution
Text replacement depends on the availability of the fonts which are used in a PDF file. If the
original font is not available the function loads an alternate font that matches the characteristics
of the original font as close as possible. However, font substitution is not perfect and a
substituted font looks sometimes more different as expected.
To improve text replacement it is possible to set one or more alternate fonts which should be
used if the original font cannot be found on the system. Alternate fonts can be loaded with
Previous topic: ParsePage
Next topic: SetAltFont