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.

Sat Mar 16, 2019 12:32 pm

I'm trying out the Free Spire.PDF and have run into something that I can't figure out. In both the Federal W-4 and state W-4 (Michigan or Arkansas...) it seems that I cannot make the checkboxes work properly. These are the fields for the federal W4 as far as I can tell it. I did find some sample code using iTextSharp that looks like it assigns a 1, 2, 3 integer value to
topmostSubform[0].Page1[0].c1_1 instead... but I don't see that control when I loop through using Spire.PDF. Any suggestions would be appreciated!

topmostSubform[0].Page1[0].c1_1[0]
topmostSubform[0].Page1[0].c1_1[1]
topmostSubform[0].Page1[0].c1_1[2]

brenda.reeves
 
Posts: 5
Joined: Thu Mar 14, 2019 8:08 pm

Mon Mar 18, 2019 3:08 am

Hello,

Thanks for your post.
Please refer to the following sample code to fill the data for checkBoxFields by Spire.PDF (at present the latest version is Spire.PDF Pack(Hot Fix) Version:5.3.2). If this is not what you want. Please provide your input PDF files as well as your desired effect of output, you could send them to us via email ([email protected]), then we will look into it and guide you accordingly.
Code: Select all
//Load pdf document
string input =@"test.pdf";
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
//Get pdf forms
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
//Fill the data for checkBoxField
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
    PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
    if (field is PdfCheckBoxWidgetFieldWidget)
    {
        PdfCheckBoxWidgetFieldWidget checkBoxField = field as PdfCheckBoxWidgetFieldWidget;
        switch (checkBoxField.Name)
        {
            case "checkBox1":
                checkBoxField.Checked = true;
                break;
            case "checkBox2":
                checkBoxField.Checked =true;
                break;
        }
    }
}
doc.SaveToFile("result.pdf", Spire.Pdf.FileFormat.PDF);

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Mon Mar 18, 2019 12:20 pm

Please find attached the Federal W-4 and below is the code I'm using. I have swapped around which boxes are marked true or false with little luck. The first and last checkbox named below can be marked as checked but the other two I haven't been able to alter.

Thanks in advance for your help!

PdfFormWidget formWidget = doc.Form as PdfFormWidget;
List<XfaField> xfafields = formWidget.XFAForm.XfaFields;
foreach (XfaField xfaField in xfafields)
{
if (xfaField is XfaCheckButtonField)
{
//Console.WriteLine("Checkbox " + xfaField.Name);
XfaCheckButtonField xf = xfaField as XfaCheckButtonField;

switch (xfaField.Name)
{
case "topmostSubform[0].Page1[0].c1_1[0]":
xf.Checked = False;
break;
case "topmostSubform[0].Page1[0].c1_1[1]":
xf.Checked = False;
break;
case "topmostSubform[0].Page1[0].c1_1[2]":
xf.Checked = True;
break;
case "topmostSubform[0].Page1[0].c1_2[0]":
xf.Checked = False;
break;
default:
break;
}

}

}

brenda.reeves
 
Posts: 5
Joined: Thu Mar 14, 2019 8:08 pm

Tue Mar 19, 2019 2:25 am

Hello,

Thanks for your more information.
I have reproduced the issue you mentioned and submitted it to our Dev team for further investigating and fixing, if there is any progress, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Thu Apr 04, 2019 11:09 am

Hello,

Greetings from E-iceblue.
Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:5.4.1, it fixed the reported issue. Please download it from the following links.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 09, 2019 8:26 am

Hello,

Greetings from E-iceblue.
Did the hotfix work for you? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 09, 2019 12:43 pm

Unfortunately the hotfix seems to only have created more problems for me. Now I am unable to successfully fill the Federal W4 form at all (none of the fields are filling in) and on the Arkansas W4 I have the same results with the checkboxes. As far as I understand the issue the forms are set up with checkbox groups and there's more than just a 'true/false' option. Did the hotfix include a different method with which I'm supposed to interact with the checkboxes?

Additionally the hotfix adds an "Evaluation Warning" that I wasn't getting previously with the Free version.

Thanks for your continued assistance.

brenda.reeves
 
Posts: 5
Joined: Thu Mar 14, 2019 8:08 pm

Wed Apr 10, 2019 6:33 am

Hello,

Thanks for your feedback.
I did notice the filled checkboxes were not displayed when opening the filled file (the attachment “myFilled.pdf” is generated on my side) by Adobe Acrobat Reader DC. However, they could be displayed correctly in Adobe Acrobat Pro, you can refer to the attached screenshot. I have submitted this issue to our Dev team for further investigating. What’s more, to make sure the investigations could fix your issue precisely, could you please tell us the PDF reader you used?
Besides, please kindly note that evaluation message will be generated when you use our commercial version without applying a valid license. Our sales team just sent a temporary license (one month free) of Spire.PDF to your email. Please check and apply it (How to apply the License by license key) to remove the evaluation message. If there is any question, welcome to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Wed Apr 10, 2019 2:07 pm

Lisa,

Thank you for the update. I am using Adobe Reader DC.

The hotfix seems to not only not display the checked boxes when I open the created file but it also no longer shows any of the other filled data. (Name, address, etc).

I do appreciate the temporary license, however for my application needs I would like to continue using the free version. I understand if this means that this issue won't be fixed in the free version and I am happy to continue helping to troubleshoot it either way.

Thanks!

brenda.reeves
 
Posts: 5
Joined: Thu Mar 14, 2019 8:08 pm

Thu Apr 11, 2019 2:28 am

Hello,

Thanks for your valuable feedback.
Yes, in Adobe Reader DC, the filled content of textBoxFields were also not displayed. I have forwarded this to our Dev team for investigating and fixing together. Once they are fixed, I will keep you informed. But as you know that, our fixes will only be included in commercial version. Sorry there is no hotfix of free version. Thanks for your understanding.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF