Radio button not visible in PDF reader

Hi!

I created a PDF for testing radio buttons from this example:
Working with AcroForms|Aspose.PDF for .NET

But in the created PDF the radio buttons have no border. I use the Acrobat Reader.

Thanks,
Daniel



Hello Daniel,


Thanks for using our products.

I have tested the scenario where I have tried specifying the border for RadioButton object using radio.IsBordered = true; and radio.BorderColor = System.Drawing.Color.FromName(“Yellow”); code lines and as per my observations, the border is not appearing in the resultant PDF document. For the sake of correction, I have logged this problem as PDFNEWNET-33811 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We are sorry for your inconvenience.

As a workaround, since the the RadioButtons are placed relative to Text paragraphs placed inside Table cells, so you may consider setting the border of Table object. Please add the following code lines and notice that border is visible in resultant file. For your reference, I have also attached the resultant PDF that I have generated.

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:green;mso-no-proof:yes”>// set the
border for table objeect<o:p></o:p>

tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

// set border to table cells

tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

Hello Nayye,

thank you for your response. In your posted PDF I can see the radio buttons how I need them. I try to create a similar PDF (with version 7.0.0) with your code suggestions but with no success: there still appears no borders . So I decided to send you my code (I also attach the result PDF):

//Instantiate the Pdf document and add a section to it
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

//Create a table, set its column widths and add it to paragraphs collection
//of the section
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

// set the border for table objeect
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

// set border to table cells
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

tab1.ColumnWidths = “120 120 120”;
sec1.Paragraphs.Add(tab1);

//Add a row to the table
Aspose.Pdf.Generator.Row r1 = tab1.Rows.Add();

//Add 1st cell to the row, set its padding and set the ID of the first paragraph
//in the cell to “text1”
Aspose.Pdf.Generator.Cell c1 = r1.Cells.Add(“item1”);
c1.Padding.Left = 30;
c1.Paragraphs[0].ID = “text1”;

//Add 2nd cell to the row, set its padding and set the ID of the first paragraph
//in the cell to “text2”
Aspose.Pdf.Generator.Cell c2 = r1.Cells.Add(“item2”);
c2.Padding.Left = 30;
c2.Paragraphs[0].ID = “text2”;

//Add 3rd cell to the row, set its padding and set the ID of the first paragraph
//in the cell to “text3”
Aspose.Pdf.Generator.Cell c3 = r1.Cells.Add(“item3”);
c3.Padding.Left = 30;
c3.Paragraphs[0].ID = “text3”;

//Create a form field of RadioButton type. Set its field name and button color.
//Then set the index of the radio button value to be checked
Aspose.Pdf.Generator.FormField radio = new Aspose.Pdf.Generator.FormField();
radio.FormFieldType = Aspose.Pdf.Generator.FormFieldType.RadioButton;
radio.FieldName = “ARadio”;
radio.ButtonColor = System.Drawing.Color.FromName(“Red”);
radio.RadioButtonCheckedIndex = 0;
radio.IsBordered = true;
radio.BorderColor = System.Drawing.Color.FromName(“Red”);

//Create 1st radio button instance and add it to above created radio form field.
//Set its width and height. The position of the radio button is set to be
//relative to the paragraph. Link this radio button with the paragraph with ID
//equal to “text1”.
Aspose.Pdf.Generator.RadioButton bt1 = radio.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = “text1”;
bt1.Left = -20;
bt1.Top = 0;

//Create 2nd radio button instance and add it to above created radio form field.
//Set its width and height. The position of the radio button is set to be
//relative to the paragraph. Link this radio button with the paragraph with ID
//equal to “text2”.
Aspose.Pdf.Generator.RadioButton bt2 = radio.RadioButtons.Add();
bt2.ButtonHeight = 12;
bt2.ButtonWidth = 12;
bt2.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt2.ReferenceParagraphID = “text2”;
bt2.Left = -20;
bt2.Top = 0;

//Create 3rd radio button instance and add it to above created radio form field.
//Set its width and height. The position of the radio button is set to be
//relative to the paragraph. Link this radio button with the paragraph with ID
//equal to “text3”.
Aspose.Pdf.Generator.RadioButton bt3 = radio.RadioButtons.Add();
bt3.ButtonHeight = 12;
bt3.ButtonWidth = 12;
bt3.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt3.ReferenceParagraphID = “text3”;
bt3.Left = -20;
bt3.Top = 0;

//Add the radio form field to the paragraphs collection of the section
sec1.Paragraphs.Add(radio);

pdf1.Save(“c:/temp/” + Guid.NewGuid() + “.pdf”);

Hello Daniel,


Thanks for sharing the code snippet.

I have tested the scenario using the code snippet that you have shared using Aspose.Pdf for .NET 7.0.0 and I am unable to notice any problem. I have tested the scenario in VisualStudio 2005 project running over Windows XP-SP3 where I have selected .NET Framework 2.0 as the target platform for my application. Can you please share some details regarding your working environment. We are sorry for your inconvenience.

For your reference, I have also attached the resultant PDF document that I have generated. Please take a look.

Hello Nayye,

thank you for your answer. My environment is VS 2010 on Windows 7. I tested the scenario with different targeted .NET versions on my machine. I also tested it on a virtual machine with VS2005 and XP SP3. But all tests produce the same faulty PDFs.

So could you please upload your Visual Studio project which you use to create the correct PDF file? Perhaps that helps me to solve problem.

By the way: my posted PDF document (result.pdf) has no bordered radio buttons in your PDF reader, too?

Thank you,
Daniel


Hello Daniel,


Thanks for your patience.

I am preparing the sample project and will upload it shortly. Sorry for the delay and inconvenience.
denyo85:
thank you for your answer. My environment is VS 2010 on Windows 7. I tested the scenario with different targeted .NET versions on my machine. I also tested it on a virtual machine with VS2005 and XP SP3. But all tests produce the same faulty PDFs.

So could you please upload your Visual Studio project which you use to create the correct PDF file? Perhaps that helps me to solve problem.
Hi Daniel,

Please find attached the sample Web Application which includes the code snippet to create a PDF document with a table containing 3 Radio buttons and as per my observations, when using this application, the resultant PDF properly shows the borders for Radio Buttons. I have tested this solution in VisualStudio 2010, running over Windows 7 where my target platform is .NET Framework 4.0. The resultant PDF that I just have created is also attached. Please take a look over b3f00e6e-5aae-430c-a17f-922eda68ebed.pdf.

denyo85:
By the way: my posted PDF document (result.pdf) has no bordered radio buttons in your PDF reader, too?
When I have tried viewing the resultant.pdf that you have shared, I am still unable to see the border around Radio buttons. See the attached Image file. Please again ensure that you are using Aspose.Pdf for .NET 7.1.0 and also please note that I am using Adobe Reader 10.1.3 to view the document.

The issues you have found earlier (filed as PDFNEWNET-33811) have been fixed in Aspose.Pdf for .NET 9.3.0.

Blog post for this release can be viewed over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Daniel,


In reference to above reported fix of PDFNEWNET-33811, You may use following DOM approach create table and set border for table cells. Hopefully it will help you to accomplish the task.

String outFile = “33811.pdf”;<o:p></o:p>

Document doc = new Document();

Page page = doc.Pages.Add();

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

table.ColumnWidths = "120 120 120";

page.Paragraphs.Add(table);

Aspose.Pdf.Row r1 = table.Rows.Add();

Aspose.Pdf.Cell c1 = r1.Cells.Add();

Aspose.Pdf.Cell c2 = r1.Cells.Add();

Aspose.Pdf.Cell c3 = r1.Cells.Add();

RadioButtonField rf = new RadioButtonField(page);

rf.PartialName = "radio";

doc.Form.Add(rf, 1);

RadioButtonOptionField opt1 = new RadioButtonOptionField();

RadioButtonOptionField opt2 = new RadioButtonOptionField();

RadioButtonOptionField opt3 = new RadioButtonOptionField();

opt1.OptionName = "Item1";

opt2.OptionName = "Item2";

opt3.OptionName = "Item3";

opt1.Width = 15;

opt1.Height = 15;

opt2.Width = 15;

opt2.Height = 15;

opt3.Width = 15;

opt3.Height = 15;

rf.Add(opt1);

rf.Add(opt2);

rf.Add(opt3);

opt1.Border = new Border(opt1);

opt1.Border.Width = 1;

opt1.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;

opt1.Characteristics.Border = System.Drawing.Color.Black;

opt1.DefaultAppearance.TextColor = System.Drawing.Color.Red;

opt1.Caption = new TextFragment("Item1");

opt2.Border = new Border(opt1);

opt2.Border.Width = 1;

opt2.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;

opt2.Characteristics.Border = System.Drawing.Color.Black;

opt2.DefaultAppearance.TextColor = System.Drawing.Color.Red;

opt2.Caption = new TextFragment("Item2");

opt3.Border = new Border(opt1);

opt3.Border.Width = 1;

opt3.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;

opt3.Characteristics.Border = System.Drawing.Color.Black;

opt3.DefaultAppearance.TextColor = System.Drawing.Color.Red;

opt3.Caption = new TextFragment("Item3");

c1.Paragraphs.Add(opt1);

c2.Paragraphs.Add(opt2);

c3.Paragraphs.Add(opt3);

c1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);

c2.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);

c3.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);

doc.Save(outFile);

Please feel free to contact us for any further assistance.


Best Regards,