Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 588

Previous Page 587   Index   Next Page 589

Function Reference
Page 588 of 750
ReplacePageText
Syntax:
LBOOL pdfReplacePageText(
const PPDF* IPDF,
// Instance pointer
const char* NewText,
// The text or NULL to delete the string
struct TPDFStack* Stack) // Operation stack
The function deletes or replaces a text string of a content stream that was found by the function
GetPageText() beforehand. If NewText is NULL the string will be deleted. The deletion of strings is
possible independent of the used font format.
However, if you want to replace a string with a new one you must check the members Embedded and
CIDFont of the structure TPDFStack to determine whether the font is not embedded and that no CID
font is in use. Because the function does not more than replacing the original string value with the
new one, it is recommended that the used font is not embedded. Embedded fonts are usually stored
as subset; only the used characters are embedded. If the new string contains characters which are not
included in the font, the string looks misplaced and unsupported characters will be replaced with the
.notdef character when viewing the file.
Strings of CID fonts cannot be replaced with this function because such strings are binary strings
which cannot be created outside of the library.
However, it is usually best to use this function to delete the original string if necessary. The new text
can be written with the function WriteTextMatrixEx() or use ReplacePageTextEx() instead.
If a text record consists of more than one kerning record, it is possible to preserve an arbitrary
number of kerning records from deletion. This can be archieved by setting the member
DeleteKerningAt of the structure TPDFStack to the whished kerning record number before calling this
function. All kerning records above this number will be deleted. Note that the parameter NewText is
ignored in this case.
DynaPDF is delivered with the example edit_text which demonstrates how texts can be replaced in a
document. If you want to develop a text replacement algorithm please take a look into this example.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
ReplacePageTextEx
Syntax:
LBOOL pdfReplacePageTextEx(
const PPDF* IPDF,
// Instance pointer
const char* NewText,
// New text or NULL to delete the string
struct TPDFStack* Stack) // Operation stack
The function deletes or replaces a text string of a content stream that was found by the function
GetPageText() beforehand. The function requires a font that must be set with SetFont() or
 

Previous topic: ReplaceICCProfile

Next topic: ResetLineDashPattern