static void DrawFormFields(PdfGraphics graphics) { // Create a text box field and specify its location on the page. PdfGraphicsAcroFormTextBoxField textBox = new PdfGraphicsAcroFormTextBoxField("text box", new RectangleF(30, 10, 200, 30)); // Specify text box text, and appearance. textBox.Text = "Text Box"; textBox.Appearance.FontSize = 12; textBox.Appearance.BackgroundColor = Color.AliceBlue; // Add the text box field to graphics. graphics.AddFormField(textBox); // Create a radio group field. PdfGraphicsAcroFormRadioGroupField radioGroup = new PdfGraphicsAcroFormRadioGroupField("First Group"); // Add the first radio button to the group and specify its location using a RectangleF object. radioGroup.AddButton("button1", new RectangleF(30, 60, 20, 20)); // Add the second radio button to the group. radioGroup.AddButton("button2", new RectangleF(30, 90, 20, 20)); // Specify radio group selected index, and appearance. radioGroup.SelectedIndex = 0; radioGroup.Appearance.BorderAppearance = new PdfGraphicsAcroFormBorderAppearance() { Color = Color.Red, Width = 3 }; // Add the radio group field to graphics. graphics.AddFormField(radioGroup); }
static void DrawSignatureField(PdfGraphics graphics) { // Create a signature field specifying its name and location. PdfGraphicsAcroFormSignatureField signature = new PdfGraphicsAcroFormSignatureField("signature", new RectangleF(0, 20, 120, 130)); // Specify a content image for the signature field. Image image = Image.FromFile("..\\..\\Image.png"); signature.ContentImage = image; // Add the field to the document. graphics.AddFormField(signature); }
static void DrawTextBoxField(PdfGraphics graphics) { // Create a text box field and specify its location on the page using a RectangleF object. PdfGraphicsAcroFormTextBoxField textBox = new PdfGraphicsAcroFormTextBoxField("text box", new RectangleF(0, 10, 200, 30)); // Specify text box properties. textBox.Text = "Text Box"; textBox.TextAlignment = PdfAcroFormStringAlignment.Near; textBox.Appearance.FontSize = 12; textBox.Appearance.BackgroundColor = Color.AliceBlue; // Add the field to graphics. graphics.AddFormField(textBox); }
static void DrawCheckBoxField(PdfGraphics graphics) { // Create a check box field specifying its name and location. PdfGraphicsAcroFormCheckBoxField checkBox = new PdfGraphicsAcroFormCheckBoxField("check box", new RectangleF(20, 20, 30, 30)); // Specify check box appearance, checked state, and button style. checkBox.Appearance.BackgroundColor = Color.Azure; checkBox.Appearance.BorderAppearance = new PdfGraphicsAcroFormBorderAppearance() { Color = Color.Red }; checkBox.IsChecked = true; checkBox.ButtonStyle = PdfAcroFormButtonStyle.Star; // Add the field to the document. graphics.AddFormField(checkBox); }
static void DrawListBoxField(PdfGraphics graphics) { // Create a list box field specifying its name and location. PdfGraphicsAcroFormListBoxField listBox = new PdfGraphicsAcroFormListBoxField("list box", new RectangleF(20, 20, 100, 120)); // Add values to the list box. listBox.AddValue("Blue"); listBox.AddValue("Green"); listBox.AddValue("Red"); listBox.AddValue("Yellow"); // Specify list box appearance, text alignment, and select value. listBox.Appearance.BackgroundColor = Color.Aqua; listBox.TextAlignment = PdfAcroFormStringAlignment.Far; listBox.SelectValue("Blue"); // Add the field to the document. graphics.AddFormField(listBox); }
static void DrawComboBoxField(PdfGraphics graphics) { // Create a combo box field specifying its name and location. PdfGraphicsAcroFormComboBoxField comboBox = new PdfGraphicsAcroFormComboBoxField("combo Box", new RectangleF(20, 20, 100, 20)); // Add values to the combo box. comboBox.AddValue("Red"); comboBox.AddValue("Yellow"); comboBox.AddValue("Green"); comboBox.AddValue("Blue"); // Specify combo box selected value, text allignment, and appearance. comboBox.SelectValue("Red"); comboBox.TextAlignment = PdfAcroFormStringAlignment.Far; comboBox.Appearance.BackgroundColor = Color.Beige; comboBox.Appearance.FontSize = 14; // Add the field to the document. graphics.AddFormField(comboBox); }
static void DrawRadioButtonGroupField(PdfGraphics graphics) { // Create a radio group field. PdfGraphicsAcroFormRadioGroupField radioGroup = new PdfGraphicsAcroFormRadioGroupField("First Group"); // Add the first radio button and specify its location using a RectangleF object. radioGroup.AddButton("button1", new RectangleF(0, 0, 20, 20)); // Add the second radio button. radioGroup.AddButton("button2", new RectangleF(0, 20, 20, 20)); // Specify radio group selected index, style and appearance. radioGroup.SelectedIndex = 1; radioGroup.ButtonStyle = PdfAcroFormButtonStyle.Circle; radioGroup.Appearance.BackgroundColor = Color.Aqua; radioGroup.Appearance.BorderAppearance = new PdfGraphicsAcroFormBorderAppearance() { Color = Color.Red, Width = 3 }; // Add the field to graphics. graphics.AddFormField(radioGroup); }