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 Aug 18, 2020 6:25 pm

Hi,

Can Spire PDF get the location of a certain field(Field1) name, fill it with text and insert extra text after that field without causing overlap to the field(Field2) after?

For example:
“MemberName1” (Field1)
“MemberName2” (inserted text)
“MemberName3” (inserted text) etc…
Field2

Thanks
Steve

hsiungst
 
Posts: 2
Joined: Tue Aug 18, 2020 6:20 pm

Wed Aug 19, 2020 10:28 am

Hi,

Thanks for your inquiry.
Our Spire.PDF could fulfill your requirment. Please refer to the following code. If there is any problem, please provide your input Pdf document as well as your expected output for further investigation. Thanks in avdance.
Code: Select all
 PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"sample.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 "Text1":
                            string a = textBoxField.Text;
                            textBoxField.Text = a + "your text";
                            break;
                    }
                }
            }
            doc.SaveToFile("FillFormField.pdf", FileFormat.PDF);


Sincerely,
Lynn
E-iceblue support team
User avatar

lynn.zhang
 
Posts: 57
Joined: Mon Jul 27, 2020 2:27 am

Wed Aug 19, 2020 11:25 am

Hi Lynn, the code shown just concatenates the text together? that's not my intention - I would like to insert several lines of text after textbox field Name1 without disturbing the next field like so:

1st Line - textbox field Name1 (populate with text)
2nd Line - Insert Text
3rd Line - Insert text etc.. - this action automatically pushes the next field Name2 down

textbox field Name2

Thanks
Steve

hsiungst
 
Posts: 2
Joined: Tue Aug 18, 2020 6:20 pm

Thu Aug 20, 2020 2:27 am

Hi,

Thanks for your information.
Sorry that the feature you want is not supported in our Spire.Pdf. The essence of inserting text into PDF is to draw text on PDF without automatically pushing the next objects down. If there is any other question, please feel free to contact us.

Sincerely,
Lynn
E-iceblue support team
User avatar

lynn.zhang
 
Posts: 57
Joined: Mon Jul 27, 2020 2:27 am

Return to Spire.PDF

cron