I working with interactive text boxes and for some reason the text in the text box doesn’t keep it’s font. When I generate the PDF, the text font is the one I set, but if I click inside the text box, the text become Helvetica. If I don’t type anything in it and click out, the font goes back to what I set, but if I type some text in it, the font remains Helvetica even after I click out.
I tried to set the default appearance through the DA string, tried the TextWidget.SetAppearance() with appearance stream, the SetFont() function and so on, but it always reset like I said.
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
It seems like you’re experiencing an issue with maintaining the font appearance in a TextWidget form field when interacting with it. This can occur if the appearance stream or the default appearance (DA) string is not properly set or updated after user interaction. Let’s explore how you can address this issue.
Some things you can try:
Ensure that the TextWidget.SetFont(), SetFontSize(), and SetTextColor() methods are correctly applied to the form field before saving the document.
Use TextWidget.RefreshAppearance() after setting the font properties to ensure the appearance stream is updated.
Check if the NeedAppearances flag is set in the AcroForm dictionary; if so, try clearing it to prevent automatic appearance generation by viewers.
Verify that the font you’re setting is embedded in the PDF to avoid fallback to default fonts like Helvetica.
This is Kaden from the Apryse Support Team – I see that you marked that AiRon’s response to your initial post solved your issue. I’m glad to hear that it was helpful. If you have any additional questions or issues in your use of the Apryse SDK, please feel free to reach out.
Thanks,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team
Unfortunately the problem is still persist. With the bot’s advice I can set the font and works fine, but if I set the font to bold_italic, then after writing in the field the font turns to just bold.
I’m glad to hear that you were able to resolve the initial issue in which the font would set to Helvetica when being edited, but I understand you’re still encountering a font-related issue when it comes to text’s italicization after editing the field.
Can you indicate whether this issue occurs while editing the field, or after the edits to the field are saved? Furthermore, can you provide a code block that shows how you’re currently utilizing the PDFNet SDK to apply these edits to the text field?
Thank you,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team
The loss of the italic style could happen for a few reasons:
Make sure the font you’re using actually supports both bold and italic. If it doesn’t, the SDK might swap it out for the closest match.
Also, try setting the Appearance Stream for the TextWidget after you choose the font. That should help keep your customizations intact.
If you can, share a bit of your code so we can see how you’re setting the font properties.
Here’s a sample code snippet for updating the Appearance Stream:
Thanks for providing that information & a code snippet. It looks like you’re setting the font correctly with the SDK – can you indicate what you’re using to test this font issue, i.e. in what application are you seeing the font change during edit?
Furthermore, can you provide a sample file in which you are seeing this issue so that I may attempt to reproduce the issue on my end?
Best,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team
I see the issue both in Acrobat reader and browsers. I also have a problem with setting a different font that a standard type1font. The issue is the same. In this PDF I created the font like this: pdftron.PDF.Font font = pdftron.PDF.Font.Create(_text.GetSDFObj().GetDoc(), "Helvetica-BoldItalic", Text);
In this PDF the text rolls back into helvetica when you want to edit the field’s value. Also if I set e.g. “Arial” it also rolls back to Helvetica. output.pdf (4.6 KB)
I also tried to get the font name after I set it and I get Helvetica.
Thank you for this additional information and the sample output PDF that you’ve provided. I am seeing the same behavior on my end, and as such, I have submitted a report to our Engineering team regarding this issue. I will reach out on this forum when I receive any updates regarding this report from our Engineering team. In the meantime, if you have any additional questions or issues, please feel free to ask here or create a new post – apologies for the inconvenience!
Best,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team
I also tried to get the embedded fonts from the PDF into a dictionary, but it gets the font names from the indirect Objs like this:
Do you have any idea why is that?
I currently do not have any workarounds that I can provide after further investigation, however, we are still taking a look at this issue internally. I will inform you if I have any new information to provide regarding the report that was made, or if a potential workaround is discussed. Thank you for your patience in this matter.
Best,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team
Unfortunately, there are currently no updates regarding the report that was made for this issue. If you have any other questions or issues related to this post, please feel free to add them here!
Thanks,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team