-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
37 lines (29 loc) · 1.41 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using DevExpress.Pdf;
using System.Drawing;
namespace AddCheckBoxField {
class Program {
static void Main(string[] args) {
using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
// Create an empty document.
processor.CreateEmptyDocument("..\\..\\Result.pdf");
// Create graphics and draw a check box field.
using (PdfGraphics graphics = processor.CreateGraphics()) {
DrawCheckBoxField(graphics);
// Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics);
}
}
}
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);
}
}
}