Problem inserting multiple radio button form fields.to PDF

I am hoping someone can help me. I am struggiling to create a PDF that has multiple radio button form fields on the same section (1 after the other) I am using the latest version of aspose PDF and starting with a blank PDF document that is created in code (PDF pdf = new PDF():wink:


The below code I have used is working if it is called 1 time and I am only looking to render 1 radio button form field with multiple choices (I.e. yes,no).

My problem is when I call the method multiple times to create multiple radio button form fields 1 after the other. The first table with 2 cells is created ok with a radio button item in each cell (yes in one and no in the other), however when the second table is created for the second Radio button form field it appears in the second cell of the first form fields table. Similar happens for the third control (it appears in the second cell of the second form fields table) this keeps on going until the indentation goes off the page.

Can someone tell me where I have went wrong or instruct me on how to insert multiple radio button form fields onto a section in the PDF (in a table or on its own, If the table around the radio form field is the problem it is not needed)

Please note this.ID in the below code is a unique guid very time the method is called and the items list is a list of string values (e.g. Yes,no)

public override bool RenderOffline(Aspose.Pdf.Generator.Pdf pdf, ApplicationFormDocumentType documentType,Aspose.Pdf.Generator.Section section)
{

section.Paragraphs.Add(new Text(string.Format("{0} {1}", this.ShowName ? this.Name : “”, this.Details != string.Empty ? string.Format("
{0}", this.Details) : “”)));

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”;
section.Paragraphs.Add(tab1);

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

foreach (var item in this.Items)
{
Aspose.Pdf.Generator.Cell c1 = r1.Cells.Add(item.Text);
c1.Padding.Left = 30;
c1.Paragraphs[0].ID = item.Text + this.ID.ToString();
}

Aspose.Pdf.Generator.FormField radio = new Aspose.Pdf.Generator.FormField();
radio.FormFieldType = Aspose.Pdf.Generator.FormFieldType.RadioButton;
radio.FieldName = this.ID.ToString();
radio.ButtonColor = System.Drawing.Color.FromName(“Red”);
radio.RadioButtonCheckedIndex = 0;
radio.IsBordered = false;
radio.BorderColor = System.Drawing.Color.FromName(“Red”);

foreach (var item in this.Items)
{
Aspose.Pdf.Generator.RadioButton bt1 = radio.RadioButtons.Add();
bt1.ButtonHeight = 12;
bt1.ButtonWidth = 12;
bt1.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
bt1.ReferenceParagraphID = item.Text + this.ID.ToString();
bt1.Left = -20;
bt1.Top = 0;
}

section.Paragraphs.Add(radio);
section.Paragraphs.Add(new Text(“test”));
return true;
}


Thanks in advance

Can anyone help me with this as it is quite urgent.

Hi,


Thanks for using our products and sorry for the delayed response.

I am working over this query/requirement and will get back to you soon.

Hi Graeme,


Sorry for the delayed response. Please check attached code snippet to create multiple radio buttons in a Pdf document. Hopefully it would help you to accomplish your requirements. If there is any confusion, then please share your sample project. So we will look into it and provide you more information.


Please feel free to contact us for any further assistance.

<span style=“font-size:11.0pt;line-height:115%;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-bidi-font-family:Arial;mso-ansi-language:
EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>

<span style=“font-size:11.0pt;line-height:115%;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-bidi-font-family:Arial;mso-ansi-language:
EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>
Best Regards,

Hi tilal,


Thanks for the code example.

The main difference between what you do in your example and in mine is that you add multiple radio button lists to the same table. i.e. you have 3 radio button lists each with 2 options in the same table (1 on each row).

In my example i cannot have them all in the same table as there may be things in-between the radio button lists that cannot be part of the same table .

Your code works however when i try to separate these into a table for each radio button list the problem happen.

any work around for this or is this a bug you can fix?

Regards
Graeme

Hi Graeme,


Sorry for the inconvenience faced. I’m afraid, I couldn’t get your requirement. Could you please share some sample desired output document? So we look into it and will provide your more information accordingly.

Thanks for your patience and understanding.

Best Regards,

Hi Tilal,


Unfortunately i cannot get you a sample document however i will try and explain again what we are trying to achieve.

Basically each item we put on the pdf is it own thing so i wanted each radio button list to be in its own separate table.

We will have other types of control on the pdf as well which will display very different in between the radio button lists so didnt want it to all be in the same table.

an example layout would be

Section 1

1) Radio button list 1 (options: 1, 2, 3) in a table with each option in its own cell

2) Some text not in a table

3) A multi line text box with a title in its own table

4) Radio button list 2 (options: 4, 5, 6) in a table with each option in its own cell

5) Some kind of an image again not in a table

6) Radio button list 3 (options: 7, 8, 9) in a table with each option in its own cell


etc

the above layout is an example of what 1 section could contain. We will have multiple sections with thousands of possibility of content combinations.

Does this make sense as to how our examples are different and why i cannot have all the radio button lists in a single table and need them separated into their own tables?

Kind Regards
Graeme

Hi Graeme,


Sorry for the inconvenience faced. I have managed to reproduce the issue at my end and logged it as PDFNEWNET-34842 in our bug tracking system for further investigation and resolution. You will be notified via this thread as soon as it gets resolved.


Thanks for your cooperation and understanding.


Best Regards,

Thanks Tilal,


I will look forward to this being fixed. do you have any idea of a time scale for the fix or work around?

Thanks
Graeme

Hi Graeme,


As we recently have been able to notice this problem and until or unless we have investigated this issue in details, I am afraid we might not be able to share the timelines by which this problem will be resolved. Nevertheless, as soon as we have made some progress towards its resolution, we would be more than happy to update you with the status of correction.

Please be patient and spare us little time. We are sorry for this inconvenience.

Is there any update on when this will be fixed? It is a fairly major issue that is stopping me using the product properly


Regards
Graeme

Hi Graeme,


Sorry for the inconvenience faced. I’m afraid, the reported issue is still not resolved due to some other priority tasks and it’s pending in the queue for analysis. I’ve requested the development team to share the ETA at their earliest and as soon as I get a feedback I’ll update you via this forum thread.

Thanks for your patience and understanding.

Best Regards

Hi Graeme,


Thanks for your patience.

We have further investigated the problem reported earlier and in order to generate correct output, please try using the new DOM approach. Please try using the following code snippet. For your reference, I have also attached the resultant PDF which is generated over my end.

[C#]

string outFile = “c:/pdftest/34842.pdf”;<o:p></o:p>

Document doc = new Document();

Page page = doc.Pages.Add();

//Instantiate a table object

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

//Add the table in paragraphs collection of the desired section

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "100 100";

//Create rows in the table and then cells in the rows

RadioButtonField rf = new RadioButtonField(page);

rf.PartialName = "radio";

doc.Form.Add(rf, 1);

RadioButtonOptionField opt1 = new RadioButtonOptionField();

RadioButtonOptionField opt2 = new RadioButtonOptionField();

opt1.OptionName = "Item1";

opt2.OptionName = "Item2";

opt1.Width = 12;

opt1.Height = 12;

opt2.Width = 12;

opt2.Height = 12;

rf.Add(opt1);

rf.Add(opt2);

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

opt1.Border = new Border(opt1);

opt1.Border.Width = 1;

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

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

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

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

opt2.Border = new Border(opt1);

opt2.Border.Width = 1;

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

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

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

Aspose.Pdf.Row row = tab1.Rows.Add();

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

c1.Paragraphs.Add(opt1);

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

c2.Paragraphs.Add(opt2);

page.Paragraphs.Add(new TextFragment(""));

page.Paragraphs.Add(new TextFragment(""));

page.Paragraphs.Add(new TextFragment("Hello world"));

//Instantiate another table object

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

//Add the table in paragraphs collection of the desired section

page.Paragraphs.Add(tab2);

//Set with column widths of the table

tab2.ColumnWidths = "100 100";

//Create rows in the table and then cells in the rows

rf = new RadioButtonField(page);

rf.PartialName = "radio";

doc.Form.Add(rf, 1);

opt1 = new RadioButtonOptionField();

opt2 = new RadioButtonOptionField();

opt1.OptionName = "Test1";

opt2.OptionName = "Test2";

opt1.Width = 12;

opt1.Height = 12;

opt2.Width = 12;

opt2.Height = 12;

rf.Add(opt1);

rf.Add(opt2);

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

opt1.Border = new Border(opt1);

opt1.Border.Width = 1;

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

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

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

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

opt2.Border = new Border(opt1);

opt2.Border.Width = 1;

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

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

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

row = tab2.Rows.Add();

c1 = row.Cells.Add();

c1.Paragraphs.Add(opt1);

c2 = row.Cells.Add();

c2.Paragraphs.Add(opt2);

doc.Save(outFile);

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


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