Product: PDFTron SDK (C++)
Product Version: 11.3.8.5075
We are using ElementReader/ElementWriter to iterate over the Elements in a PDF and replace existing Text. But we have a Problem with German special Characaters. I tried different Codes but can’t get it to work. Here’s the Code-Example:
pdftron::UString ustr{strTextToWrite.c_str()};
pdftron::UChar buff[strTextToWrite.Length()];
unsigned int counter{0u};
for(int i{0}; i < ustr.GetLength(); ++i)
buff[i] = ustr.GetBuffer()[i];
// Pass the UTF-16BE data to SetTextData
element.SetTextData(buff, strTextToWrite.Length());
element.UpdateTextMetrics();
writer.WriteElement(element);
strTextToWrite
contains either the original text (if nothing has changed) or some new Text, that the existing text should be replaced with.
strTextToWrite.c_str()
is of type wchar_t*
In our PDF we have Arial
as the font and special German Characters. But when iterating over the PDF and replacing the text (for testing “replacing” means, i write the text as it is already on the PDF) we have the problem that some text, where german special characters are contained not displayed anymore.
For example:
Here you see the second line, which contains an ß
After “replacing” only the ß
is displayed (which is weird, because in my opinion this should be the character that can’t be displayed?)
Obviously i am doing something wrong. But i can’t figure out what.