PDF Form Field with Kanji characters

Hello

We are using Aspose.PDF for .NET (22.10.0) to fill some PDF form text boxes with data.
The data that we are trying to insert contains kanji characters like “介来华签证简”.

After filling this text box and opening the pdf only the first two characters are shown. The others are only shown when entering in the textbox (see images).

image.png (13.4 KB)
image.png (33.0 KB)

I have seen that only the first two characters are present in the MSGothic font so this should be the reason why the others are not shown.

The font SimSun contains also the other characters but also if I add it to the FontRepository Sources the MSGothic font is still used.

It there a way to display the characters with the SimSun font (or another font with this characters)
possibly without having to set the font to the text box directly?

Here a code Snippet and the example pdf and output pdf.
Thanks

var fontSource = new FolderFontSource(@"C:\git\Test\fonts");
FontRepository.Sources.Add(fontSource);

var doc = new Document("form.pdf");

var field = (Field)doc.Form["test"];
field.Value = "test 介来 华签证简";

doc.Save(@"c:\temp\out.pdf");

form.pdf (2.0 KB)
out.pdf (105.7 KB)

@markus.estermann

We have logged this problem in our issue tracking system as PDFNET-52892. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Any updates on this?

@markus.estermann

We regret to inform you that the earlier logged ticket is not yet resolved due to other issues in the queue. It is currently being investigated and as soon as we have some fix ETA, we will share with you. Please spare us some time.

We are sorry for the inconvenience.

1 Like

@markus.estermann

If we add a line that set DefaultAppearanse for field - all Kanji characters are drawing correctly.

var doc = new Document("form.pdf");

var field = (Field)doc.Form["test"];
field.DefaultAppearance = new DefaultAppearance("SimSun", 11, System.Drawing.Color.Red);  // <---- this line added 
field.Value = "test 介来 华签证简";

doc.Save(@"c:\temp\out.pdf");

and there is no need for lines

var fontSource = new FolderFontSource(@"C:\git\Test\fonts");
FontRepository.Sources.Add(fontSource);

Please confirm if this solves your original issue?

Hi

Thank you for your reply.

Setting the font on every text box works and it’s the workaround that we are actually using, but the original question was if it is possible to automatically use a font with these characters without having to set the font to the text box directly.

When the characters “介来” are set in a text box the font is automatically changed to MSGothic (instead of using the default font Helvetica). But when setting the characters “华签证简” the font is also set to MSGothic that does not have this chars.

If it is not possible to set it automatically we’ll stick with the Default Appearance solution.

@markus.estermann

Thanks for sharing the feedback. We have recorded it and updated the ticket information. We will be writing you back as soon as we have more information in this regard.

@markus.estermann

This is not the case, and you can verify this from the code given in picture326-3.png (47.9 KB)

var doc = new Document("form.pdf"); 
var field = (Field)doc.Form["test"]; 
DefaultAppearance DAbefore = field.DefaultAppearance; field.Value = "test 介来"; 
DefaultAppearance DAafter = field.DefaultAppearance;