Q: We have encountered a unusual problem when replacing text in pdf
file. We are using it to take the address details from a .pdf file
and insert them into another .pdf file. It all seems to work ok,
except when words have an uppercase ‘R’ (eg. ‘Road’).
It does not write the uppercase ‘R’ to the newly created page. It
does write a lowercase ‘r’.
We have also noticed it does not write the follow characters we need
to accurately record details, Uppercase 'Q', 'R', 'V', 'X', 'Z', and
Below is an example of the code used.
string elementText = "rRRRRRRRRRRRr";
byte elementByte =
int tmpByteCount =
string tmpString =
Where element is declared as ‘Element’ eg(Element element);
This writes ‘rr’ on the new page.
This is within a block of code that is similar to the pdftron example
I’ve included the full block just so you can see. But the main part
is above and hard coded for test purposes.
A: The problem is that the font that is associated with a given text
element may use custom encoding or may be missing glyphs (in case of
subsetted fonts). Usually it is much simpler to use a new font and to
replace the entire text run then edit the existing element. For more
information you may want to refer to the following articles:
or search for "replace text", "edit text", "search replace" etc.