Print Page | Close Window

How do you Delete/Remove child form fields?

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2447
Printed Date: 12 Feb 26 at 1:52PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How do you Delete/Remove child form fields?
Posted By: idolpx
Subject: How do you Delete/Remove child form fields?
Date Posted: 06 Nov 12 at 11:27PM
When I call the DeleteFormField function with the ID of the child form field it deletes the parent too.
But if I save the document to a file all of the form fields are still there.

I'm using v7.26 of the library at the moment.  
I'm going to try the current version and see if that fixes it.




Replies:
Posted By: AndrewC
Date Posted: 07 Nov 12 at 3:14AM
Do you have any sample code we can look at ?

Here is some test code I wrote that is performing as expected in 9.12

            QP.LoadFromFile("formfields_2parents2children.pdf", "");

            int c = QP.FormFieldCount();
            string s = "Before DeleteFormField() - Count=" + c.ToString() + "\n";

            for (int i = 1; i <= c; i++)
                QP.SetFormFieldValue(i, i.ToString() + "_" + QP.GetFormFieldValue(i));

            for (int i = 1; i <= c; i++)
                s += String.Format("{0} : Name={1} : Value={2}\n", QP.GetFormFieldType(i), QP.GetFormFieldTitle(i), QP.GetFormFieldValue(i));

            QP.DeleteFormField(6);
            QP.DeleteFormField(2);

            c = QP.FormFieldCount();
            s += "After DeleteFormField() - Count=" + c.ToString() + "\n";

            for (int i = 1; i <= c; i++)
                s += String.Format("{0} : Name={1} : Value={2}\n", QP.GetFormFieldType(i), QP.GetFormFieldTitle(i), QP.GetFormFieldValue(i));
            MessageBox.Show(s);

            QP.SaveToFile("out.pdf");
            Process.Start("out.pdf");

Before DeleteFormField() - Count=6
7 : Name=F1 : Value=
1 : Name=F1.Child1 : Value=2_F1.Child1.Text
1 : Name=F1.Child2 : Value=3_F1.Child2.Text
7 : Name=F2 : Value=
1 : Name=F2.Child1 : Value=5_F2.Child1.Text
1 : Name=F2.Child2 : Value=6_F2.Child2.Text
After DeleteFormField() - Count=4
7 : Name=F1 : Value=
1 : Name=F1.Child2 : Value=3_F1.Child2.Text
7 : Name=F2 : Value=
1 : Name=F2.Child1 : Value=5_F2.Child1.Text

Andrew.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk