Transparent text fields in tables

I have a table with FormField objects. However, no matter how short I
make the text fields, the borders seem to be thinner where the text
field is and normal size where the text field isn’t. I still want the
user ot be able to enter text, but I would like it to be in back of the
table so that the border is consistent with the whole table. I have
attached an example screenshot. Notice the thin part of the border
where the text field is (circled in red). Is there a method or setting where the border
can go away?

Hi,

I've tested the scenario but I'm unable to reproduce the problem. Can you please share the code snippet you are using so that we can try executing it over our end.

We are sorry for your inconvenience.

Hope this code helps. I was able to reproduce the problem I had in my regular project with this simple class.

public class PDFGenerator
{
private FormField[] textField;
private static int NumberOfFields = 12;

public PDFGenerator()
{
Pdf pdf = new Pdf();
pdf.PageSetup.Margin.Left = 25;
pdf.PageSetup.Margin.Right = 25;
pdf.PageSetup.Margin.Top = 25;
pdf.PageSetup.Margin.Bottom = 25;
Section tableSection = pdf.Sections.Add();
int NumberOfFields = 100;

// Initialize the arrays
textField = new FormField[NumberOfFields];

// Initialize each check box
for (int i = 0; i < NumberOfFields; i++)
{
textField[i] = new FormField();
textField[i].FormFieldType = FormFieldType.Text;
textField[i].FormHeight = 15;
textField[i].FormWidth = 200;
textField[i].FieldName = “TextField” + i;
textField[i].IsBordered = false;
}

Table bodyTable = new Table();
bodyTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All);
bodyTable.ColumnWidths = “270 270”;
Row[] tableRows = new Row[NumberOfFields / 2];
for (int i = 0; i < NumberOfFields; i += 2)
{
int row = i / 2;
tableRows[row] = bodyTable.Rows.Add();
tableRows[row].Cells.Add().Paragraphs.Add(textField[i]);
tableRows[row].Cells.Add().Paragraphs.Add(textField[i + 1]);
}
tableSection.Paragraphs.Add(bodyTable);

MemoryStream ms = new MemoryStream();
pdf.Save(ms);
byte[] pdfByteArray = ms.ToArray();

using (BinaryWriter binWriter = new BinaryWriter(File.Open(“c:/test.pdf”, FileMode.Create)))
{
binWriter.Write(pdfByteArray);
}
}
}

Hi,

I've tested the code snippet that you've shared and noticed that the problem is occurring because the height of the FormField and table cell is equal, so its overlapping. For the sake of correction, please specify the Row height.

I've updated the code snippet and the resultant PDF that I've generated does not show the problem. Please try using it and in case it does not resolve your problem or you have any further query, feel free to contact.

The resultant PDF is also in attachment.

[C#]

Pdf pdf = new Pdf();

pdf.PageSetup.Margin.Left = 25;
pdf.PageSetup.Margin.Right = 25;
pdf.PageSetup.Margin.Top = 25;
pdf.PageSetup.Margin.Bottom = 25;

Aspose.Pdf.Section tableSection = pdf.Sections.Add();
int NumberOfFields = 100;
// Initialize the arrays
FormField[] textField = new FormField[NumberOfFields];
// Initialize each check box

for (int i = 0; i < NumberOfFields; i++)
{
textField[i] = new FormField();
textField[i].FormFieldType = FormFieldType.Text;
textField[i].FormHeight = 15;
textField[i].FormWidth = 200;
textField[i].FieldName = "TextField" + i;
textField[i].IsBordered = true;
}

Table bodyTable = new Table();
bodyTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All,new Aspose.Pdf.Color("Red"));
bodyTable.ColumnWidths = "270 270";
Row[] tableRows = new Row[NumberOfFields / 2];
for (int i = 0; i < NumberOfFields; i += 2)
{
int row = i / 2;
tableRows[row] = bodyTable.Rows.Add();
tableRows[row].FixedRowHeight = 20;
tableRows[row].Cells.Add().Paragraphs.Add(textField[i]);
tableRows[row].Cells.Add().Paragraphs.Add(textField[i + 1]);
tableRows[row].Cells[0].Alignment= AlignmentType.Center;
tableRows[row].VerticalAlignment = VerticalAlignmentType.Center;
}
tableSection.Paragraphs.Add(bodyTable);

pdf.Save("d:\\pdftest\\FormField_BorderIssue_Test.PDF");