2012-10-29 43 views
0

我们需要获取包含特定PdfTextField的PpdfPage,我们该如何做?获取包含PdfTextField的PDF页面

代码:

PdfDocument document = PdfReader.Open("C:\\filex.pdf", PdfDocumentOpenMode.Modify); 

// Get the root object of all interactive form fields 
PdfAcroForm form = document.AcroForm; 

// Get all form fields of the whole document 
PdfAcroField.PdfAcroFieldCollection fields = form.Fields; 

PdfTextField textfield1= (PdfTextField)fields["textfield1"]; 

//how to get the correct page reference respect the especified field? 
PdfPage page = textfield1.Owner.Pages[???]; 
+0

你在使用itextsharp的库是什么库? – retslig

+1

根据标签pdfsharp。 – mkl

+0

@retslig PdfSharp,我们过去使用过itextsharp,但是PdfSharp许可证更开放 – VSP

回答

0

最后我们解决了它创建这个函数:

protected int PaginaCampo(string campofirma, PdfDocument document) 
{ 
    for (int i = 0; i < document.Pages.Count; i++) 
    { 
     PdfAnnotations anotations = document.Pages[i].Annotations; 
     for (int j = 0; j < anotations.Count; j++) 
     { 
      if (anotations[j].Title != campofirma) continue; 
      return i; 
     } 
    } 
    return -1; 
} 

不是最好的解决方案,但它的工作原理......如果有人添加了一个更好的,我们将给予对他/她的正确答案

相关问题