Why do I get weird results after editing existing PDF text?


We are looking for a way to search and replace static PDF text in
existing PDF files. After a long search we run into your product,
which seems to able to do that. With the trial version we have build a
very small application to see if it works. Well.... It does, but not
always. It depends on the text we are replacing. It would be very kind
if you could give us a clue why it responds differently with every
text you try.

The problem is that the embedded font is subsetted. This means that
some glyphs that are not referenced in the document are removed from
the embedded font in order to decrease the file size. If the replaced
text is referencing glyphs that do not exist in the font, the glyphs
will not render properly. Another problem is related to text encoding.
The text you pass to PDFNet assumes that it is represented using a
specific encoding (e.g. WinANSIIEncoding or Unicode), however an
existing PDF font may use custom encoding. As a result, the modified
text may appear as junk data.

Although it is possible to implement workarounds for above issues, it
is generally simpler to replace the entire text run with a new text
run (created using ElementBuilder) that is referencing a new font (the
new font can be created based on the font name and metrics of the
existing font).

For more information on this topic please, please search for "edit
text" in PDFNet SDK Knowledge Base: