示例#1
0
        // add list box field for fields of the PDF document
        // with common parameters and default names.
        //
        static PdfListBox RenderListBox(C1PdfDocument pdf, string[] list, int activeIndex, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string     name    = string.Format("ACFLB{0}", _listBoxCount + 1);
            PdfListBox listBox = new PdfListBox();

            // default border
            listBox.BorderWidth = FieldBorderWidth.Thin;
            listBox.BorderStyle = FieldBorderStyle.Solid;
            listBox.BorderColor = Colors.DarkGray;

            // array
            foreach (string text in list)
            {
                listBox.Items.Add(text);
            }

            // parameters
            listBox.Font         = font;
            listBox.Name         = name;
            listBox.DefaultValue = activeIndex;
            listBox.Value        = activeIndex;
            listBox.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", string.Format("Count = {0}", listBox.Items.Count), name) : toolTip;
            if (back != Colors.Transparent)
            {
                listBox.BackColor = back;
            }

            // add
            pdf.AddField(listBox, rc);
            _listBoxCount++;

            // done
            return(listBox);
        }
示例#2
0
        public static void Main()
        {
            // NOTE:
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToFile = "Listboxes.pdf";

            using (PdfDocument pdf = new PdfDocument())
            {
                PdfPage page = pdf.Pages[0];

                PdfListBox listBox = page.AddListBox(10, 50, 120, 80);
                listBox.AddItem("First item");
                listBox.AddItem("Second item");
                listBox.AddItem("Third item");
                listBox.MultiSelection = true;

                PdfListItem[] items =
                {
                    new PdfListItem("One",   "1"),
                    new PdfListItem("Two",   "2"),
                    new PdfListItem("Three", "3"),
                };
                PdfListBox listBox2 = page.AddListBox(10, 140, 120, 80);
                listBox2.AddItems(items);
                listBox2.SelectItems(new PdfListItem[] { items[0], items[2] });

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
示例#3
0
        // add list box field for fields of the PDF document
        // with common parameters and default names.
        //
        internal PdfListBox RenderListBox(string[] list, string text, Font font, RectangleF rc, Color back, string toolTip)
        {
            // create
            string     name    = string.Format("ACFLB{0}", _listBoxCount + 1);
            PdfListBox listBox = new PdfListBox();

            // default border
            listBox.BorderWidth = FieldBorderWidth.Thin;
            listBox.BorderStyle = FieldBorderStyle.Solid;
            listBox.BorderColor = SystemColors.ControlDarkDark;

            // array
            foreach (string item in list)
            {
                listBox.Items.Add(item);
            }

            // parameters
            listBox.Font    = font;
            listBox.Name    = name;
            listBox.Text    = text;
            listBox.ToolTip = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", string.Format("Count = {0}", listBox.Items.Count), name) : toolTip;
            if (back != Color.Transparent && !back.IsEmpty)
            {
                listBox.BackColor = back;
            }

            // add
            _c1pdf.AddField(listBox, rc);
            _listBoxCount++;

            // done
            return(listBox);
        }
示例#4
0
        // add list box field for fields of the PDF document
        // with common parameters and default names.
        //  
        internal PdfListBox RenderListBox(string[] list, string text, Font font, RectangleF rc, Color back, string toolTip)
        {
            // create
            string name = string.Format("ACFLB{0}", _listBoxCount + 1);
            PdfListBox listBox = new PdfListBox();

            // default border
            listBox.BorderWidth = FieldBorderWidth.Thin;
            listBox.BorderStyle = FieldBorderStyle.Solid;
            listBox.BorderColor = SystemColors.ControlDarkDark;

            // array
            foreach (string item in list)
            {
                listBox.Items.Add(item);
            }

            // parameters
            listBox.Font = font;
            listBox.Name = name;
            listBox.Text = text;
            listBox.ToolTip = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", string.Format("Count = {0}", listBox.Items.Count), name) : toolTip;
            if (back != Color.Transparent && !back.IsEmpty)
            {
                listBox.BackColor = back;
            }

            // add
            _c1pdf.AddField(listBox, rc);
            _listBoxCount++;

            // done
            return listBox;
        }