如何使用Aspose PDF检索表单字段的页码?我试图通过放置每个页面的图像并使用页码,坐标和尺寸覆盖每个字段来重新创建HTML格式的PDF表单。
这是我目前的代码:
public static List<PdfFieldDisplayModel> GetFieldPlacements(Stream stream)
{
var fields = new List<PdfFieldDisplayModel>();
var doc = new Document(stream);
var pdfForm = new Aspose.Pdf.Facades.Form(stream);
foreach (Field ff in doc.Form)
{
var txt = doc.Form[ff.Name] as TextBoxField;
var f = new PdfFieldDisplayModel();
f.PageNumber = ??????????????
f.Name = ff.Name;
f.PartialName = ff.PartialName;
f.Value = ff.Value;
f.Width = txt.Rect.Width;
f.Height = txt.Rect.Height;
f.Left = txt.Rect.LLX;
f.Bottom = txt.Rect.LLY;
fields.Add(f);
}
return fields;
}
答案 0 :(得分:2)
我的名字是Nayyer,我是Aspose的开发者传播者。要获取表单字段的网页索引,请尝试使用 Aspose.Pdf.InteractiveFeatures.Forms.Field 实例的 PageIndex 属性。
<强> [C#] 强>
//open document
Document pdfDocument = new Document("c:/pdftest/SingleField_output.pdf","password");
//get values from all fields
foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form)
{
//get field value
Console.WriteLine("PartialName : {0} ", formField.PartialName);
Console.WriteLine("Value : {0} ", formField.Value);
Console.WriteLine("Value : {0} ", formField.PageIndex);
}