2011-11-29 4 views
4

C#과 VisualStudio를 사용하여 iTextSharp 라이브러리를 실험하고 있습니다. AcroFields 개체에서 필드 이름과 필드 형식 (TextBox, RadioButton, ComboBox, CheckBox)을 얻으려고합니다.iTextSharp를 사용하여 PDF 문서의 필드에서 필드 유형을 결정하는 방법은 무엇입니까?

필드 이름을 쉽게 찾을 수 있지만 필드 형식으로 어려움을 겪고 있습니다. 나는 iText javadoc을 확인했다. 왜냐하면 여기에있는 누군가가 메서드와 함수가 iTextSharp와 비슷해야한다고 말했기 때문에 그것이 사실이라는 것을 알지 못했기 때문이다. 나는 AcroFields 객체에서 필드 유형을 추출 할 수있는 방법에

FormObject fo = new FormObject(); 
List<FormField> form_fields = new List<FormField>(); 

PdfReader reader = new PdfReader(file_name); 
AcroFields reader_fields = reader.AcroFields; 

foreach (KeyValuePair<String, iTextSharp.text.pdf.AcroFields.Item> entry in reader_fields.Fields) 
{ 
    FormField ff = new FormField(); 
    ff.Field_name = entry.Key.ToString(); 
    form_fields.Add(ff); 
} 

어떤 아이디어 :

여기에 얻을 내 코드는 필드 이름입니다입니까? 나는 그것이 어딘가에 있어야한다는 것을 안다. ...

+2

에서 [AcroFields에 대한 문서 (http://api.itextpdf.com/itext/com/itextpdf/text/pdf/AcroFields.html#getFieldType은 (java.lang.String의는))을 의미하는 것 'AcroFields.Item' 객체가 아니라'AcroFields.getFieldType()'을 사용하여 필드 유형을 가져옵니다. – millimoose

+0

내일 정보를 찾아 주셔서 감사합니다. – pteranodonjohn

답변

2

오늘 아침에 들판 타입을 발견 할 수 있었다.

FormObject fo = new FormObject(); 
List<FormField> form_fields = new List<FormField>(); 

PdfReader reader = new PdfReader(file_name); 
AcroFields reader_fields = reader.AcroFields; 



foreach (KeyValuePair<String, iTextSharp.text.pdf.AcroFields.Item> entry in reader_fields.Fields) 
{ 
    FormField ff = new FormField(); 
    ff.Field_name = entry.Key.ToString(); 
    int field_type = reader_fields.GetFieldType(entry.Key.ToString()); 
    form_fields.Add(ff); 
} 
관련 문제