Form fields

Technical support for Spire.PDF

Moderator: iceblue support

Form fields

Postby mthomper » Mon Apr 02, 2012 1:04 am

Is it possible to populate formfields in an existing pdf?
How can I get a list of formfields from an existing document?
mthomper
 
Posts: 1
Joined: Tue Mar 27, 2012 1:45 am

Re: Form fields

Postby Suvi.Wu » Tue Apr 03, 2012 6:06 am

Hi,

So sorry that our product doesn't support to populate formfields in an existing pdf at this stage. We will consider adding it in our future upgrade.

Thanks for your feedback.
Have a gerat day!

BR
Suvi
e-iceblue
User avatar
Suvi.Wu
 
Posts: 156
Joined: Thu Oct 20, 2011 2:53 am

Re: Form fields

Postby amy.zhao » Wed Jan 08, 2014 2:22 am

Hello,

The feature has been supported. Welcome to test the latest version of Spire.PDF(http://www.e-iceblue.com/Download/downl ... t-now.html).
Sample code:

Code: Select all
  static void Filldata()
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"..\..\FormField.pdf");
            PdfFormWidget formWidget = doc.Form as PdfFormWidget;
            for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
            {
                PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
                if (field is PdfTextBoxFieldWidget)
                {
                    PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
                    switch (textBoxField.Name)
                    {
                        case "email":
                            textBoxField.Text = "support@e-iceblue.com";
                            break;
                        case "username":
                            textBoxField.Text = "E-iceblue";
                            break;
                        case "password":
                            textBoxField.Password = true;
                            textBoxField.Text = "e-iceblue";
                            break;
                        case "password2":
                            textBoxField.Password = true;
                            textBoxField.Text = "e-iceblue";
                            break;
                        case "company_name ":
                            textBoxField.Text = "E-iceblue";
                            break;
                        case "first_name":
                            textBoxField.Text = "James";
                            break;
                        case "last_name":
                            textBoxField.Text = "Chen";
                            break;
                        case "middle_name":
                            textBoxField.Text = "J";
                            break;
                        case "address1":
                            textBoxField.Text = "Chengdu";
                            break;
                        case "address2":
                            textBoxField.Text = "Beijing";
                            break;
                        case "city":
                            textBoxField.Text = "Shanghai";
                            break;
                        case "postal_code":
                            textBoxField.Text = "11111";
                            break;
                        case "state":
                            textBoxField.Text = "Shanghai";
                            break;
                        case "phone":
                            textBoxField.Text = "1234567901";
                            break;
                        case "mobile_phone":
                            textBoxField.Text = "123456789";
                            break;
                        case "fax":
                            textBoxField.Text = "12121212";
                            break;
                    }
                }
                if (field is PdfListBoxWidgetFieldWidget)
                {
                    PdfListBoxWidgetFieldWidget listBoxField = field as PdfListBoxWidgetFieldWidget;
                    switch (listBoxField.Name)
                    {
                        case "email_format":
                            int[] index = { 1 };
                            listBoxField.SelectedIndex = index;
                            break;
                    }
                }

                if (field is PdfComboBoxWidgetFieldWidget)
                {
                    PdfComboBoxWidgetFieldWidget comBoxField = field as PdfComboBoxWidgetFieldWidget;
                    switch (comBoxField.Name)
                    {
                        case "title":
                            int[] items = { 0 };
                            comBoxField.SelectedIndex = items;
                            break;
                    }
                }

                if (field is PdfRadioButtonListFieldWidget)
                {
                    PdfRadioButtonListFieldWidget radioBtnField = field as PdfRadioButtonListFieldWidget;
                    switch (radioBtnField.Name)
                    {
                        case "country":
                            radioBtnField.SelectedIndex = 1;
                            break;
                    }
                }

                if (field is PdfCheckBoxWidgetFieldWidget)
                {
                    PdfCheckBoxWidgetFieldWidget checkBoxField = field as PdfCheckBoxWidgetFieldWidget;
                    switch (checkBoxField.Name)
                    {
                        case "agreement_of_terms":
                            checkBoxField.Checked = true;
                            break;
                    }
                }
                if (field is PdfButtonWidgetFieldWidget)
                {
                    PdfButtonWidgetFieldWidget btnField = field as PdfButtonWidgetFieldWidget;
                    switch (btnField.Name)
                    {
                        case "submit":
                            btnField.Text = "Submit";
                            break;
                    }
                }
            }
            doc.SaveToFile(@"../../FormFieldData.pdf.pdf");
            System.Diagnostics.Process.Start(@"../../FormFieldData.pdf.pdf");
        }
You do not have the required permissions to view the files attached to this post.
User avatar
amy.zhao
 
Posts: 2251
Joined: Wed Jun 27, 2012 8:50 am

Re: Form fields

Postby callaway20 » Tue Apr 22, 2014 1:41 pm

Does this feature work in the free version?

Error occurs at:

For i As Integer = 0 To formWidget.FieldsWidget.List.Count - 1
callaway20
 
Posts: 2
Joined: Fri Apr 11, 2014 7:03 pm

Re: Form fields

Postby Gary.zhang » Wed Apr 23, 2014 3:24 am

Hello,

Thanks for your inquiry.
Sorry that it doesn't work in this Free version, but it will work in next free version we are preparing. Once it is published, we will let you know.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Form fields

Postby callaway20 » Thu Apr 24, 2014 4:21 pm

Great. Thanks for the reply. Building an app for pdf file creation and form fill for inspection reports. Your software is the ticket.
callaway20
 
Posts: 2
Joined: Fri Apr 11, 2014 7:03 pm

Re: Form fields

Postby Gary.zhang » Thu May 15, 2014 9:11 am

Hello,

The newest Free Spire.Pdf has just been published, you can download and test Free Spire.PDF for .NET Version:3.0

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Form fields

Postby mrviceguy@gmail.com » Tue Dec 09, 2014 5:05 pm

Dear support,

We are using your Free Spire.PDF library via nuget in our project. Version is 3.0.26.56040.
Although the fields are successfully enumerated in the code and populated with data, the exported PDF does not contain the form data. I have uploaded a test project for review - it contains the pdf and the codebase we are using.

Best Regards,
Gergő
You do not have the required permissions to view the files attached to this post.
mrviceguy@gmail.com
 
Posts: 1
Joined: Tue Dec 09, 2014 4:49 pm

Re: Form fields

Postby amy.zhao » Wed Dec 10, 2014 3:10 am

Dear Gergő,

Thanks for your inquiry.
Sorry for the inconvenience caused by Free Spire.PDF. It does have the issue, we only maintain our free version of Spire.PDF when we have enough time.

I recommend you try the latest commercial Spire.PDF Pack Version:3.2.0. It can resolve your issue.

Downloading link: http://www.e-iceblue.com/downloads/spire.pdf_3.2.0.zip

Best wishes,
Amy
E-iceblue support team.
User avatar
amy.zhao
 
Posts: 2251
Joined: Wed Jun 27, 2012 8:50 am

Re: Form fields

Postby joey0129 » Wed Dec 10, 2014 5:06 pm

That kind of sounds like a bait and switch.
joey0129
 
Posts: 5
Joined: Wed Dec 03, 2014 3:36 pm

Re: Form fields

Postby amy.zhao » Thu Dec 11, 2014 8:52 am

Dear Gergő,

Did Spire.PDF Pack Version:3.2.0 resolve your issue?
Thanks for your feedback.

Best wishes,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2251
Joined: Wed Jun 27, 2012 8:50 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 0 guests