iTextSharp를 사용하면 PDF 양식에있는 양식 필드를 모두 검색 할 수 있습니다. Adobe Acrobat Reader를 사용하여 모든 필드에 위치 속성이있는 PDF를 편집하고 있습니다. PDF 필드가 양식에있는 위치를 나타냅니다.PDF 형식 필드 위치 검색 Itext
제 질문은, 저 값을 읽을 수 있습니까?
예를 들어 PDF 양식에 양식 필드 이름이있는 경우 왼쪽 0.5 인치, 오른쪽 2.5 인치, 위쪽 2 인치, 아래쪽 2 인치와 같은이 필드의 위치 값을 얻을 수 있습니까?
는 지금은 아래의 코드를 사용하여 양식 필드를 검색 해요 :
string pdfTemplate = @"D:\abc.pdf";
PdfReader reader = new PdfReader(pdfTemplate);
var fields = reader.AcroFields;
int ffRadio = 1 << 15; //Per spec, 16th bit is radio button
int ffPushbutton = 1 << 16; //17th bit is push button
int ff;
//Loop through each field
foreach (var f in fields.Fields)
{
String type = "";
String name = f.Key.ToString();
String value = fields.GetField(f.Key);
//Get the widgets for the field (note, this could return more than 1, this should be checked)
PdfDictionary w = f.Value.GetWidget(0);
//See if it is a button-like object (/Ft == /Btn)
if (!w.Contains(PdfName.FT) || !w.Get(PdfName.FT).Equals(PdfName.BTN))
{
type = "T";
}
else
{
//Get the optional field flags, if they don't exist then just use zero
ff = (w.Contains(PdfName.FF) ? w.GetAsNumber(PdfName.FF).IntValue : 0);
if ((ff & ffRadio) == ffRadio)
{
//Is Radio
type = "R";
}
else if (((ff & ffRadio) != ffRadio) && ((ff & ffPushbutton) != ffPushbutton))
{
//Is Checkbox
type = "C";
}
else
{
//Regular button
type = "B";
}
}
//MessageBox.Show(type + "=>" + name + "=>" + value);
FormFields fld = new FormFields(name, type, value, "inputfield" +form_fields.Count);
form_fields.Add(fld);
if (type.Equals("T"))
addContent(form_fields.Count);
}