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.

Tue Jul 18, 2017 4:19 am

Hi,

I downloaded Spire.PDF tonight. I need to fill in the fields in a PDF form and then print the document. When I followed your code sample, it is not finding any fields. What might I be doing wrong? Below is a snippet of my code and I've attached the exact file that I need to fill in via code. Thanks so much.

PdfDocument pdf;
pdf = new PdfDocument();
pdf.LoadFromFile(@"M:\Forms\CFIA - Phyto Application.pdf", Spire.Pdf.FileFormat.PDF);
PdfFormWidget formWidget = pdf.Form as PdfFormWidget;
int x = pdf.Form.Fields.List.Count;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
}

waldav00
 
Posts: 3
Joined: Tue Jul 18, 2017 2:55 am

Tue Jul 18, 2017 6:30 am

Dear waldav00,

Thanks for your inquiry.
The forms in your PDF are XFA forms, so please use following code to get forms in your PDF.
Code: Select all
            PdfFormWidget formWidget = pdf.Form as PdfFormWidget;
            for (int i = 0; i < formWidget.XFAForm.XfaFields.Count; i++)
            {

            }


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jul 18, 2017 2:14 pm

Thanks so much for the quick response. I am now getting the error message:
'Spire.Pdf.Widget.PdfFormWidget; does not contain a definition for 'XFAForm'.

Any ideas why?

waldav00
 
Posts: 3
Joined: Tue Jul 18, 2017 2:55 am

Wed Jul 19, 2017 1:40 am

Dear waldav00,

Thanks for your response.
Please upgrade to the latest Spire.PDF Pack(Hot Fix) Version:3.9.189. Below is the dll information for checking.
Spire.license.dll V1.3.6.40
Spire.Pdf.dll V3.9.189.2040

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Jul 19, 2017 3:35 am

Thank you so much! Now it works perfectly.

waldav00
 
Posts: 3
Joined: Tue Jul 18, 2017 2:55 am

Wed Jul 19, 2017 3:43 am

Dear waldav00,

Thanks for your feedback.
Please feel free to contact us if there is any question.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF