Accessing fields on forms added to existing PDFS using ASPOSE

We added forms to existing pdfs in order to track certain values. We make good use of AddFieldAppearance. However fields that use this feature are not available in the Fields list of the final aspose document.


Attached is such a document. I’m able to see the fields using ADOBE X however I am unable to get to the fields using ASPOSE.

Please advise. Your prompt response is very very appreciated!

kindly,
linda

Hi Linda,


Thanks for your inquiry. I have investigated your PDF form, it contains 23 fields, 5 fields (s1,s2A,s2R,s2L and total) have duplicate copies on subsequent pages. So if you are getting 23 fields then it is expected behavior. However if there is any difference in your issue and my understanding then please share some more details here, so we will look into it and will guide you accordingly.

Best Regards,

Running this simple check…only fields that are not duplicated are returned using the Aspose.Pdf. Thank you for your assistance.


static void ShowValues(string path)
{
Document pdfDocument = new Document(path);
// Get values from all fields

Console.WriteLine(">>> Show Values for " + path);
foreach (Field formField in pdfDocument.Form)
{
Console.WriteLine(“Field Name: {0} Field Value: {1}”, formField.PartialName, formField.Value);
}

Console.ReadLine();
}

Also please know that I have been able to get to the fields and values using ADOBE Reader and more recently freeware used to read pdfs.

thank you again.

Hi Linda

Thanks for your feedback. You can get value and position of these duplicate fields using Aspose.Pdf as following.

var pdf1 = new Document(@"D:/Downloads/Q01-01001.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.Annotations.Annotation annot in field)
        {
            Console.WriteLine("Field Name: {0}, Field Value: {1}, Field Type: {2}, Page number: {3}, count: {4}, rect: {5}", 
                fieldFullName, field.Value, fieldType, facadeField.PageNumber, field.Count, annot.Rect);
        }
    }
    else
    {
        Console.WriteLine("Field Name: {0}, Field Value: {1}, Field Type: {2}, Page number: {3}, count: {4}", 
            fieldFullName, field.Value, fieldType, facadeField.PageNumber, field.Count);
    }
}

Please feel free to contact us for any further assistance.

Best Regards,

Thank you so much for your prompt support. :slight_smile: That worked perfectly.

kind regards,
linda

Hi Linda,


Thanks for your feedback. It is good to know that suggested code worked for you.

Please keep using our API and feel free to contact us for any query or concern, we will be more than happy to extend our support.

Best Regards,