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
lowercase 'z'.
Below is an example of the code used.
string elementText = "rRRRRRRRRRRRr";
byte[] elementByte =
System.Text.ASCIIEncoding.ASCII.GetBytes(elementText);
int tmpByteCount =
System.Text.ASCIIEncoding.ASCII.GetByteCount(elementText);
string tmpString =
System.Text.ASCIIEncoding.ASCII.GetString(elementByte);
element.SetTextData(elementByte, tmpByteCount);
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
‘EditTextTest.cs’
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:
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/8394e67025f558d9
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/74b709f5a426d348
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/7b51b00ac6699609
or search for "replace text", "edit text", "search replace" etc.