We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ComboBox font changed after selecting a value

Hi,

I have a simple pdf document with one ComboBox (please see Input.pdf). The font I used is Helvetica.
I’m running the following code:

var doc = new Document("D:/Input.pdf");
var comboBox = (ComboBoxField)doc.Form.First();
comboBox.Selected = 1;
doc.Save("D:/Output.pdf");

When I open Output.pdf in Chrome, the displayed font is Times New Roman. However, when I expand the list, the options use Helvetica. Also, when I choose the value manually (Chrome or Acrobat), save the file and open it again in Chrome, the font is Helvetica again.

Could you please advise why the font changes and how to avoid it?
I’m using Aspose.PDF for .Net v21.11.0 with licence.

Thanks,
Michał

Input.pdf (6.3 KB)
Output.pdf (76.9 KB)
EditedManuallyAcrobat.pdf (78.1 KB)

@acturisaspose

We checked the Output.pdf file by opening it in both Chrome and Adobe Reader. The font of selected value gets changed in Chrome whereas it remains correct in Adobe. Please note that we cannot control what and how Chrome viewer shows the PDF document. Furthermore, the API mimics the behavior of Adobe Reader and we could not reproduce the font changing issue while opening the PDF in Adobe Reader. Please feel free to let us know in case you have further concerns.

Thanks for your fast response. Could you please take a further look?

Using the files previously attached, I’m running the following code:

var selectedWithAspose = new Document("D:/Output.pdf");
var comboBoxAspose = selectedWithAspose.Form.First();
var normalAppearanceAspose = comboBoxAspose.Appearance["N"];
var fontSelectionAspose = normalAppearanceAspose.Contents.OfType<Aspose.Pdf.Operators.SelectFont>().First();
Console.WriteLine($"Aspose: {fontSelectionAspose.Name}");

var selectedWithAdobe = new Document("D:/EditedManuallyAcrobat.pdf");
var comboBoxAdobe = selectedWithAdobe.Form.First();
var normalAppearanceAdobe = comboBoxAdobe.Appearance["N"];
var fontSelectionAdobe = normalAppearanceAdobe.Contents.OfType<Aspose.Pdf.Operators.SelectFont>().First();
Console.WriteLine($"Adobe: {fontSelectionAdobe.Name}");

The results are:

Aspose: C0_0
Adobe: Helv
  1. Could this be considered a difference between the API result and the expected document?
  2. Is there a way to change the font of a ComboBox (and other fields) using Aspose.Pdf?

@acturisaspose

We were also able to reproduce the similar behavior by the API in our environment. We need to further investigate this scenario in details in order to come up with a solution to such issues. For the sake, an issue as PDFNET-51052 has been logged in our issue management system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.