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

Free Support Forum - aspose.com

Facades.Form() not displaying the textbox form fields with background color and border


I have a PDF with form fields in it. In below, i'm setting the background color, value, style and border width for the text box form fields "allergies_label_pg1", "allergies_label_pg3" and saving to "result.pdf".

var dataDir = Directory.GetCurrentDirectory();
var tmpPath = Path.GetTempPath();
var doc = new Aspose.Pdf.Document(dataDir + @"\sample.pdf");
var textBoxField1 = doc.Form["allergies_label_pg1"] as TextBoxField;
textBoxField1.Value = "sample text value 1";
textBoxField1.Characteristics.Background = System.Drawing.Color.FromArgb(255, 204, 204);
textBoxField1.Characteristics.Border = System.Drawing.Color.Red;
textBoxField1.Border.Width = 1;
textBoxField1.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;
var textBoxField2 = doc.Form["allergies_label_pg3"] as TextBoxField;
textBoxField2.Value = "sample text value 2";
textBoxField2.Characteristics.Background = System.Drawing.Color.FromArgb(255, 204, 204); ;
textBoxField2.Characteristics.Border = System.Drawing.Color.Red;
textBoxField2.Border.Width = 1;
textBoxField2.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;
// save the resultant file
doc.Save(tmpPath + @"\result.pdf");

Later, i'm filling the other form fields using the below code.

var pdfForm = new Aspose.Pdf.Facades.Form();
pdfForm.BindPdf(tmpPath + @"\result.pdf");
pdfForm.FillField("weight_pg1", Weight);
pdfForm.FillField("height_pg1", Height);
pdfForm.FillField("Sex", sex);
pdfForm.FillField("M_2", sex == "M" ? "On" : "Off");
pdfForm.FillField("F_2", sex == "F" ? "On" : "Off");
pdfForm.FillField("Sex_3", sex); pdfForm.FillField("Sex_4", sex);
pdfForm.Save(tmpPath + @"\finalResult.pdf")

The problem here is that the text box fields "allergies_label_pg1" and "allergies_label_pg3" are not visible in the "finalResult.pdf" file.

Any help will be appreciated.

Hi Rajesh,

Thanks for your inquiry. We will appreciate if you please share your sample PDF document here. We will test the scenario and will provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,

Thanks for your reply.
I have attached the sample file.

Hi Rajesh,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for .NET 9.2.0, we have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-36918 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,