DynaPDF Manual - Page 57
Previous Page 56 Index Next Page 58
Content parsing & editing
Page 57 of 860
(see GetPageBBox()). Note also that the width and height must be exchanged if the orientation is
90, -90, 270, or -270 degrees.
The page coordinate system is de-rotated since this produces better results and it is much easier
to find the location of text in rotated pages.
FindText() is usually called inside a loop until no more occurrences of the search string can be
found. The search result of the last call must be passed to the parameter Last so that the function
knows where to continue. In the first call, Last must be set to NULL. That means start at the
beginning.
SelText and Last can point to the same structure. The values are copied before the function is
executed.
Example (C++):
TTextSelection sel, *curr;
for (SI32 i = 1; i <= pdfGetPageCount(pdf); i++)
{
curr = NULL; // Important! Must be NULL in the first call.
if (psrParsePage(pdf, ctx, NULL, NULL, i, cpfEnableTextSelection, 0, &out))
{
while (psrFindText(pdf, ctx, NULL, stDefault, curr, sText, sLen, &sel))
{
psrReplaceSelText(pdf, ctx, rtfDefault, &sel, rText, rLen);
curr = &sel; // Required! Otherwise the search run starts over and over again at the
// beginning and this would cause an endless loop.
}
psrWriteToPage(pdf, ctx, ofDefault, NULL);
}
}
Return values:
If text was found the return value is 1. If no text was found or if an error occurred the return
value is false.
GetSelBBox
Syntax:
LBOOL psrGetSelBBox(
const PPDF* IPDF,
// PDF instance pointer
const IPSR* Ctx,
// Parser instance pointer
TTextSelection* SelText, // Required. Structure filled with data by
// FindText().
TBBox* BBox)
// Required. Address of a TBBox structure
The function computes the bounding box of the current selection created by FindText().
Notice:
The bounding box is calculated in top down coordinates! This differs in comparison to
almost all other functions which return PDF coordinates.
Previous topic: FindText, Optional search area
Next topic: GetSelBBox2