Returning to properties of default fonts when using ContentReplacer

Hi

When I try to chage a certain letters of embedded fonts by using ContentReplacer of PDFTron, the letters themselves change as I want.
However, I found that the properties of embedded fonts, such as the space between letters, are gone and then return to those of the default.

The source which I tested on is the sample program that PDFTron offer in its website.

Could you deal with this problem?

2016년 1월 28일 목요일 오전 2시 47분 38초 UTC+9, Jaehyon Park 님의 말:

Hi

When I try to chage a certain letters of embedded fonts by using ContentReplacer of PDFTron, the letters themselves change as I want.
However, I found that the properties of embedded fonts, such as the space between letters, are gone and then return to those of the default.

The source which I tested on is the sample program that PDFTron offer in its website.

Could you deal with this problem?

  • Please note that letters in the red boxes on the right hand side return to those on the left hand side with different properties.

https://trello-attachments.s3.amazonaws.com/56a88620d40ee073fe4ee2a3/305x567/189c8b8b236e008e053d947b5ddba473/ContentsReplacer_Compare.png

ContentReplacerCS.zip (4.34 MB)

PDFNet is checking the operating system for the best font match. You can control this using the PDFNet.AddFontSubst functions, to explicitly tell PDFNet which font file on the OS to use for particular fonts.

It would be possible to first check if the font being replaced is embedded in the PDF, and if so, to see if those characters are in the font file, but it is not clear if this is ever true (typically embedded fonts are subsetted, and only include what is actually already in the PDF).

The other option is to not use ContentReplacer, but instead TextSearch class and the ElementReader and ElementWriter classes to replace the text, giving you full control over this replacement. This of course is more code, but gives you full control.