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.

Wed Dec 27, 2017 8:29 am

Hi E-iceblue support team,
I using Spire.PDF to read all fields from a *.pdf file, for .NET application.
I faced with a problem when determine the page for the PdfTextBoxFieldWidget which have the same name, and it belong to multiple page on the document.
Example: On page 2 of the document, it contains a textbox with named is "Month".
On page 4, it also contains a textbox with named is "Month".
And so on for another pages.

I traverse PdfFormWidget.FieldsWidget.List of the document. And see that all PdfTextBoxFieldWidget which have the same name just loaded all into a PdfField.WidgetItems.List (PdfField = PdfFormWidget.FieldsWidget.List[index]).

Each item on PdfField.WidgetItems.List is PdfTexBoxWidgetItem. And I using this method(doc.Pages.IndexOf(item page)) to get the page of each item in this list PdfField.WidgetItems.List. But the "IndexOf" method always return the page of first item in PdfField.WidgetItems.List list; even if the item is on another page, it always return the first page.
Could you help me to find out any solution for this problem.
It is my code snippet.
This line: fieldDTO.Page = doc.Pages.IndexOf(tmpTextBox.Page) + 1; // It always return the page of widgetItems[0]
Code: Select all
var doc = new PdfDocument();
doc.LoadFromBytes(System.IO.File.ReadAllBytes(@"\file.pdf"));
var formWidget = doc.Form as PdfFormWidget;
//List<PDFFormField> lstFieldPDF = new List<PDFFormField>();
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
     PDFFormField fieldDTO = new PDFFormField();
     PdfField fieldPDF = formWidget.FieldsWidget.List[i] as PdfField;
     if (fieldPDF is PdfTextBoxFieldWidget)
     {
          PdfTextBoxFieldWidget textBoxField = fieldPDF as PdfTextBoxFieldWidget;
          if (textBoxField.WidgetItems != null && textBoxField.WidgetItems.List != null && textBoxField.WidgetItems.List.Count > 0)
          {
               var widgetItems =  textBoxField.WidgetItems.List;
               for (int j = 0; j < widgetItems.Count; j++)
               {
                    fieldDTO.FieldPDFName = textBoxField.Name + " " + j;
                    var tmpTextBox = (widgetItems[j] as PdfTexBoxWidgetItem);
                    fieldDTO.Page = doc.Pages.IndexOf(tmpTextBox.Page) + 1; // It always return the page of widgetItems[0]
                    //lstFieldPDF.Add(new PDFFormField(fieldDTO));
                }
          }
     }
}


Updated: so sorry for "fieldDTO", please comment out what related to this variable, and just focus on this doc.Pages.IndexOf(tmpTextBox.Page) + 1; to detect the issue. Many thanks
Last edited by longnt on Wed Dec 27, 2017 4:28 pm, edited 3 times in total.

longnt
 
Posts: 4
Joined: Thu Dec 21, 2017 9:42 am

Wed Dec 27, 2017 10:08 am

Hello,

Thanks for your feedback. To help us investigate the issue, please share us with your PDF document. You could attach it here or send to our email([email protected]).

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Dec 27, 2017 10:17 am

This is my sample pdf file I work for. There are some textboxs which have the same name in different pages. Ex: Month, Day, Year...

longnt
 
Posts: 4
Joined: Thu Dec 21, 2017 9:42 am

Wed Dec 27, 2017 12:05 pm

Hello,

Thanks for the information, I have noticed the issue and posted it to our Dev team, once it is resolved, or we have some other update, we will let you know.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Dec 27, 2017 4:42 pm

Thanks you for reply, I would like to getting a good news from the Dev team. Thanks.

longnt
 
Posts: 4
Joined: Thu Dec 21, 2017 9:42 am

Mon Jan 08, 2018 7:39 am

Hello,

Glad to inform you that the issue has been fixed. Welcome to download Spire.PDF Pack(Hot Fix) Version:3.9.584.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Jan 10, 2018 3:03 am

Hello,

Greeting from E-iceblue.
Has the hotfix resolved your issue?
We will appreciate it if you could give us some feedback.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 16, 2018 1:59 pm

Thanks for your reply,
I will check it.
Thank you very much.

longnt
 
Posts: 4
Joined: Thu Dec 21, 2017 9:42 am

Tue Jan 23, 2018 8:19 am

Hello,

Hope you are doing fine.
Did you try the hotfix? Is the issue fixed?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support teama
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.PDF

cron