Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

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

$
0
0
Hi,

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");
                    doc.Dispose();

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.


Viewing all articles
Browse latest Browse all 3131

Trending Articles