ComboBoxField border issue - Java

Hi,

I am not able to get the visible border for ComboBoxField in java. I am attaching the file for required vs Aspose issue.

In Image, left hand side combo box format is the one we are looking for with border and right hand side is showing the one we got without border with Aspose library.

So please let me know, how would I be able to set the border in aspose as shown in left hand side of image.

Please provide code snippet in Java and not in .Net, please.

Thanks

combo_box_issue_aspose.png (1.7 KB)

@darshpatel

You may please use following code snippet to add border around a ComboBoxField:

Document doc = new Document();
Page page = doc.getPages().add();
ComboBoxField combo = new ComboBoxField(page, new Rectangle(100, 600, 150, 616));
combo.addOption("Red");
combo.addOption("Yellow");
combo.setBorder(new Border(combo));
combo.getBorder().setWidth(3);
doc.getForm().add(combo);
doc.save(dataDir + "comboboxwithborder.pdf");

@asad.ali

Hi,

I tried given snippet but I ended up with the same result, so can you please make sure the given code has border when ComboBoxField is on PDF.

Thanks

@darshpatel

Would you kindly share the output PDF file that was generated on your end while using suggested code snippet?

@asad.ali

Here it is.

HelloWorld_out.pdf (64.6 KB)

Thanks

@darshpatel

The border is there in the generated output but it only appears when we mouse hover upon combo box. We have logged an investigation ticket in our issue tracking system as PDFJAVA-39200. We will further investigate the reasons behind this behavior of the API and keep you posted with the status of ticket resolution. Please spare us some time.

We are sorry for the inconvenience.

@asad.ali

Just to it clear, when hover on combobox, border does not appear.

The normal behaviour should be as follow:

  • Combobox should show border irrespective of focus or hovering.
  • Combobox hwould show first item in combobox and not the blank when there is no option chosen.
  • If user clicks on it, it would show border to options which are visible in combobox. (This is already there)

FYI, we are planning to buy this library, so please provide better insight about how long issue will take to resolve.

Thanks

@darshpatel

Please use the following code to show border always:

combo.getCharacteristics().setBorder(Color.getBlack());

You can set a selected value using the following code:

combo.setValue("Red");

@asad.ali

This is a bit different than I asked before but as it does belong to Comobox, I am asking here.

combo.addOption(“export”, “name”);

As above, addOption method of Combobox takes two arguments, one is export and another one is name.

Once I add this to Comobox, is there any way I am able to retrieve both export and name after PDF is generated and after at retrieval time.

I am looking for this, as I have to attach code for all the options added to Combox.

If you not clear, please let me know.

Thanks

@darshpatel

Please use following code snippet to achieve what you require:

doc = new Document(dataDir + "comboboxwithborder.pdf");
ComboBoxField cmb = (ComboBoxField)doc.getForm().get_Item(1);
for(Option opt:cmb.getOptions()) {
    System.out.println(opt.getName());
    System.out.println(opt.getValue());
}