Hi,
Environment: Libraries 10.3 and 10.9.0 (release Oct 2,2015)
I want to extract Adobe form fields and noticed that out of 68, only 35 are extracted. Why is that the case? How can I extract all 68 of them?
I attached document reg135.pdf as a use case.
I use the following code to extract location coordinates of the form fields:
//Step 1: Get all Adobe fields.
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(filename);
Aspose.Pdf.Facades.FormFieldFacade fieldfacade = null;
string field_value = null;
//get all field names
String[] allfields = form.FieldNames;
Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;
foreach (string mFieldName in allfields)
{
try
{
fieldfacade = form.GetFieldFacade(mFieldName);
field_value = form.GetField(mFieldName);
Aspose.Pdf.Page pdfPage = pageCollection[textFragment.Page.Number];
if (String.IsNullOrEmpty(field_value)){
//Break it down & form the json data
System.Drawing.Rectangle box = fieldfacade.Box;
dynamic adobe_ft = new System.Dynamic.ExpandoObject();
adobe_ft.page_number = fieldfacade.PageNumber - 1;
adobe_ft.required = form.IsRequiredField(mFieldName);
adobe_ft.x = box.X;
adobe_ft.label = mFieldName;
adobe_ft.y = pdfPage.MediaBox.Height - box.Y - box.Height;
adobe_ft.width = box.Width;
adobe_ft.height = box.Height;
mAdobeDefinedfields.Add(adobe_ft);
fieldfacade.Reset();// resets all visual attributes to empty value.
}
} catch(Exception e){
if (e.Message.Contains(“cannot”))
{
// Trace.WriteLine("---- Field cannot be found: "+mFieldName);
}
}
Questions:
1. How can I get all 68 form fields with the code given above? Can you please suggest a solution? Or let me know if this is a bug?
2. This is follow up for another issue: Form Fields positions not extracted correctly and you’ve logged a ticket for it: PDFNEWNET-39486 to correct the height values of form fields extracted. When is the fix for this expected?
Thank you,
Sireesha
sireesha.charyulu:
Questions:
1. How can I get all 68 form fields with the code given above? Can you please suggest a solution? Or let me know if this is a bug?
var pdf1 = new Document("reg135.pdf");
var formtyp = pdf1.Form.Type;
var pdfForm = new Aspose.Pdf.Facades.Form(pdf1);
foreach (var field in pdf1.Form.Fields)
{
var fieldFullName = field.FullName;
var facadeField = pdfForm.GetFieldFacade(fieldFullName);
var fieldType = pdfForm.GetFieldType(fieldFullName);
if (field.Count > 0)
{
foreach (Aspose.Pdf.InteractiveFeatures.Annotations.Annotation annot in field)
{
//System.Console.WriteLine(annot.Rect);
Console.WriteLine("Field Name: {0}, Field Type: {1}, count: {2}, rect: {3}", fieldFullName, fieldType,field.Count, annot.Rect);
}
}
else
Console.WriteLine("Field Name: {0}, Field Type: {1}, count: {2}", fieldFullName, fieldType,field.Count);
}
sireesha.charyulu:
Questions:
2. This is follow up for another issue: https://forum.aspose.com/t/27990 and you've logged a ticket for it: PDFNEWNET-39486 to correct the height values of form fields extracted. When is the fix for this expected?
Thank you… looking forward for the fix on (2)issue.
Hi Sireesha,