Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sun Feb 18, 2024 1:24 am

I can't find a way to grab the export value text for PdfRadioButtonWidgetItems - ie the data from the `/Opt` entry in the Radio button field dictionary from the PDF format spec.

See example below, I have a set of radio widget items with text values set to "Choice1", "Choice2", "Choice3" etc in Acrobat, but in the code I'm only getting "0", "1", "2" etc. I've attached a PDF that minimally reproduces this issue. Thanks in advance.

Image
Image

davidhoare
 
Posts: 2
Joined: Sun Feb 18, 2024 12:58 am

Sun Feb 18, 2024 3:45 am

Hello,

Thank you for your inquiry.
Since the screenshot you provided is not visible, I tested the PDF file you provided using Spire.PDF Pack (Hot Fix) Version:10.2.2 and the value of the PdfRadioButtonWidgetItem is available in full. Here is my test code for your reference.
Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("RadioMinimal.pdf");
//Get all form fields
PdfFormWidget formWidget = pdf.Form as PdfFormWidget;

StringBuilder builder = new StringBuilder();

//Loop through all fields
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
    PdfField field = formWidget.FieldsWidget.List[i] as PdfField;

    //Find the radio button field
    if (field is PdfRadioButtonListFieldWidget)
    {
        PdfRadioButtonListFieldWidget radio = field as PdfRadioButtonListFieldWidget;
        PdfRadioButtonWidgetWidgetItemCollection collection = radio.WidgetWidgetItems;
        for (int r = 0; r < collection.Count;r++)
        {
            PdfRadioButtonWidgetItem item = collection[r];
            string value = item.Value;
            builder.AppendLine(String.Format("The button style of Radio button value is: " + value));
        }
     
    }
}

string result = "RadioButton_Value.txt";

//Save the document
File.WriteAllText(result, builder.ToString());

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Feb 19, 2024 10:12 am

Hi Annika,

Thanks for your reply - it looks like this is a divergence of functionality between Spire.PDF and FreeSpire.PDF. Running your sample code with Spire.PDF indeed gives the correct values, but when linked with the free version we get the following incorrect output. Is this a known limitation?

Code: Select all
The button style of Radio button value is: 0
The button style of Radio button value is: 1
The button style of Radio button value is: 2
The button style of Radio button value is: 3
The button style of Radio button value is: 4
The button style of Radio button value is: 5
The button style of Radio button value is: 6

davidhoare
 
Posts: 2
Joined: Sun Feb 18, 2024 12:58 am

Tue Feb 20, 2024 1:15 am

Hello,

Thank you for your feedback.

Based on the information you provided, I have tested the PDF file you mentioned using the free version. I was able to reproduce the issue you pointed out. This appears to be a bug in the free version of Spire.PDF, and unfortunately, bug fixes are specific to the commercial version. As we only regularly maintain the commercial version, the free version may not receive targeted updates for this issue.

If you have any further questions or concerns, please feel free to reach out. We are here to assist you.


Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron