Dear Aspose support,
I need some help in processing a specific PDF document. My goal is to get every Adobe field in this document and its position + coordinates. Then, remove them from the document by flattening the document. What is the quickest way to do this? The attached document takes more than 60 seconds. I want it to take less time. Can you please review my algorithm below and suggest a faster alternative approach?
//Step 1: Get all Adobe fields.
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(filename);
Aspose.Pdf.Facades.FormFieldFacade fieldfacade = null;
//Ste 2: Get all field names
String[] allfields = form.FieldNames;
foreach (string mFieldName in allfields)
{ // Loop through each of adobe field
try{
fieldfacade = form.GetFieldFacade(mFieldName);
//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 = 792 - box.Y - box.Height;
adobe_ft.width = box.Width;
adobe_ft.height = box.Height;
} catch(Exception e){
if (e.Message.Contains("cannot"))
{
// Trace.WriteLine("---- Field cannot be found: "+mFieldName);
}
}
}//End of ForEach loop
// Step 3:remove all form fields
pdfDocument.Flatten();
I need some help in processing a specific PDF document. My goal is to get every Adobe field in this document and its position + coordinates. Then, remove them from the document by flattening the document. What is the quickest way to do this? The attached document takes more than 60 seconds. I want it to take less time. Can you please review my algorithm below and suggest a faster alternative approach?
//Step 1: Get all Adobe fields.
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(filename);
Aspose.Pdf.Facades.FormFieldFacade fieldfacade = null;
//Ste 2: Get all field names
String[] allfields = form.FieldNames;
foreach (string mFieldName in allfields)
{ // Loop through each of adobe field
try{
fieldfacade = form.GetFieldFacade(mFieldName);
//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 = 792 - box.Y - box.Height;
adobe_ft.width = box.Width;
adobe_ft.height = box.Height;
} catch(Exception e){
if (e.Message.Contains("cannot"))
{
// Trace.WriteLine("---- Field cannot be found: "+mFieldName);
}
}
}//End of ForEach loop
// Step 3:remove all form fields
pdfDocument.Flatten();