Aspose.Pdf

How to create Inline RadioButton

Inline RadioButton means that creating RadioButton with in a Text. Text is a paragraph that contains characters and Inline Radiobutton worked inline with characters present in a Text but their function is same as normal RadioButtons These radioButtons can be added into the Table as a Text. The following example will demonstrate how we can use this in paragraph of Text and in Table.

 

The structure of Inline RadioButton is shown in the Diagram below.

 

 

Here is the code to create the Inline RadioButtons in a Text:

 

Code Snippet

 

[C#]

 

  //Create Pdf Instance

  Pdf pdf1 = new Pdf();

 

  //Add A Section

  Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

 

  //Add Text Paragraph

  Aspose.Pdf.Text text1 = new Text();

  sec1.Paragraphs.Add(text1);

  text1.Segments.Add("This is a test for inline radiobutton:    ");

 

  text1.InlineRadioButtonFieldName = "inlineradio";

  text1.InlineRadioButtonCheckedIndex = 1;

 

  // Add segments

  Segment seg1 = text1.Segments.Add();

 

  //1st Radio Button and set the Inline Paragraph property of segment equal to radioButton 

  Aspose.Pdf.RadioButton radio1 = new Aspose.Pdf.RadioButton();

  seg1.InlineParagraph = radio1;

 

  Segment seg11 = text1.Segments.Add("radio1  ");

 

  Segment seg2 = text1.Segments.Add();

 

  Aspose.Pdf.RadioButton radio2 = new Aspose.Pdf.RadioButton();

  radio2.ID = "radio2";

  seg2.InlineParagraph = radio2;

 

  Segment seg22 = text1.Segments.Add("radio2  ");

 

  Segment seg3 = text1.Segments.Add();

  Aspose.Pdf.RadioButton radio3 = new Aspose.Pdf.RadioButton();

  seg3.InlineParagraph = radio3;

 

  Segment seg33 = text1.Segments.Add("radio3  ");

 

  //Save the Pdf

  pdf1.Save(@"D:\AsposeTest\InLineRadioButton.pdf");

 

[VB.NET]

 

  'Create Pdf Instance

  Dim pdf1 As New Pdf()

 

  'Add A Section

  Dim sec1 As Aspose.Pdf.Section = pdf1.Sections.Add()

 

  'Add Text Paragraph

  Dim text1 = New [Text]()

  sec1.Paragraphs.Add(text1)

  text1.Segments.Add("This is a test for inline radiobutton:    ")

 

  text1.InlineRadioButtonFieldName = "inlineradio"

  text1.InlineRadioButtonCheckedIndex = 1

 

  ' Add segments

  Dim seg1 As Segment = text1.Segments.Add()

 

'1st Radio Button and set the Inline Paragraph property of segment equal to radioButton 

  Dim radio1 As New Aspose.Pdf.RadioButton()

  seg1.InlineParagraph = radio1

 

  Dim seg11 As Segment = text1.Segments.Add("radio1  ")

 

  Dim seg2 As Segment = text1.Segments.Add()

 

  Dim radio2 As New Aspose.Pdf.RadioButton()

  radio2.ID = "radio2"

  seg2.InlineParagraph = radio2

 

  Dim seg22 As Segment = text1.Segments.Add("radio2  ")

 

  Dim seg3 As Segment = text1.Segments.Add()

  Dim radio3 As New Aspose.Pdf.RadioButton()

  seg3.InlineParagraph = radio3

 

  Dim seg33 As Segment = text1.Segments.Add("radio3  ")

 

  'Save the Pdf

  pdf1.Save("D:\AsposeTest\InLineRadioButton.pdf")

 

To create Inline RadioButtons using XML please check the following:

 

[XML]

 

<?xml version="1.0" encoding="utf-8" ?>

<Pdf xmlns="Aspose.Pdf" BackgroundColor="White">

  <Section>

    <Text>

      <Segment>in Part...............</Segment>

    </Text>

    <Text>

      <Segment> </Segment>

    </Text>

 

    <Text FontSize="9" InlineRadioButtonCheckedIndex="9">

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>FormField Group1:  FontSize=12, ButtonWidth="12"  ButtonHeight="12"  InlineRadioButtonCheckedIndex="7" TAB TAB#$TAB#$TAB</Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>

        <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

      </Segment>

      <Segment>#$NL</Segment>

    </Text>

 

    <Text>

      <Segment>in TableCell...............</Segment>

    </Text>

    <Text>

      <Segment> </Segment>

    </Text>

 

    <Table ColumnWidths="120 120">

      <Row>

        <Cell PaddingLeft="30">

          <Text ID="text1">

            <Segment>Group3:  item1</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment> item1</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>item1</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>item1</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

          </Text>

        </Cell>

        <Cell PaddingLeft="30">

          <Text ID="text2" InlineRadioButtonFieldName="cc">

            <Segment>Group4:  item2#$TAB</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment> item2#$TAB</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>item2#$NL</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

            <Segment>item2</Segment>

            <Segment>

              <RadioButton ButtonWidth="12" ButtonHeight="12"></RadioButton>

            </Segment>

          </Text>

        </Cell>

      </Row>

    </Table>

 

  </Section>

</Pdf>

 

The output produced with this XML is shown below:

 

 

To get further details about RadioButton please visit our online API documents.