We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Form Fields with same Name

Hello, I have a pdf with many form fields that have the same name.
2 questions:

  1. Is it possible to obtain the collection of all the fields?
  2. The location does not belong to any of the form fields

This my code:

     string ruta1 = @"C:\\borrar\\pruebaPdf.pdf";
        string ruta2 = @"C:\\borrar\\pruebaPdf_SALIDA.pdf";
        Document opdf = new Document(ruta1);

        MessageBox.Show("Encontrado " + opdf.Form.Fields.Length.ToString() + " formularios");
        Aspose.Pdf.Forms.TextBoxField campo = opdf.Form.Fields[0] as Aspose.Pdf.Forms.TextBoxField;

        TextFragment textFragment = new TextFragment("(LOCALIZADO)");
        textFragment.Position = new Position(campo.Rect.LLX, campo.Rect.LLY);
        textFragment.TextState.FontSize = 12;
        textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");
        textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
        textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

        TextBuilder textBuilder = new TextBuilder(opdf.Pages[campo.PageIndex]);
        // Append the text fragment to the PDF page



PRUEBAPDF.pdf (3.5 KB)

Thank you!


We were able to notice in our environment while using Aspose.PDF for .NET 19.5 that API is not extracting all text boxes from your PDF. However, could you please explain a bit more about your original requirements. By looking at your code snippet, it seems like you want to get location of text box so that you can place a TextFragment against it. In case our understandings are correct, please confirm. We will further proceed accordingly.

Yes, I want to create a textbox just in the position of the form, but the location is wrong when there is more than one occurrence.

Thank you


We have logged an issue as PDFNET-46512 in our issue tracking system. We will further investigate the reasons behind this behavior of the API and let you know in case we have additional updates. Please be patient and spare us little time.

We are sorry for the inconvenience.