Example #1
0
        // add radio button box field for fields of the PDF document
        // with common parameters and default names.
        //
        public static PdfRadioButton RenderRadioButton(C1PdfDocument pdf, bool value, string group, string text, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string         name        = string.IsNullOrEmpty(group) ? "ACFRGR" : group;
            PdfRadioButton radioButton = new PdfRadioButton();

            // parameters
            radioButton.Name         = name;
            radioButton.DefaultValue = value;
            radioButton.Value        = value;
            radioButton.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Colors.Transparent)
            {
                radioButton.BackColor = back;
            }

            // add
            var radioSize = font.Size;
            var radioTop  = rc.Top + (rc.Height - radioSize) / 2;

            pdf.AddField(radioButton, new Rect(rc.Left, radioTop, radioSize, radioSize));
            _radioButtonCount++;

            // text for radio button field
            var x = rc.Left + radioSize + 1.0f;
            var y = rc.Top + (rc.Height - radioSize - 1.0f) / 2;

            pdf.DrawString(text, new Font(font.Name, radioSize, font.Style), Colors.Black, new Point(x, y));

            // done
            return(radioButton);
        }
        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 = "RadioButtons.pdf";

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

                page.Canvas.DrawString(10, 50, "Docotic.Pdf library is written using: ");

                PdfRadioButton radioButton = page.AddRadioButton("languages", 10, 60, 100, 15, "C#");
                radioButton.ExportValue = "csharp";
                radioButton.Checked     = true;

                PdfRadioButton radioButton2 = page.AddRadioButton("languages", 10, 80, 100, 15, "Python");
                radioButton2.ExportValue = "python";
                radioButton2.Checked     = false;

                pdf.Save(pathToFile);
            }

            Console.WriteLine($"The output is located in {Environment.CurrentDirectory}");
        }
Example #3
0
        // add radio button box field for fields of the PDF document
        // with common parameters and default names.
        //
        internal PdfRadioButton RenderRadioButton(bool value, string group, string text, Font font, RectangleF rc, Color back, string toolTip)
        {
            // create
            string         name        = string.IsNullOrEmpty(group) ? "ACFRGR" : group;
            PdfRadioButton radioButton = new PdfRadioButton();

            // parameters
            radioButton.Name         = name;
            radioButton.DefaultValue = value;
            radioButton.Value        = value;
            radioButton.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Color.Transparent && !back.IsEmpty)
            {
                radioButton.BackColor = back;
            }

            // add
            float radioSize = font.Size;
            float radioTop  = rc.Top + (rc.Height - radioSize) / 2;

            _c1pdf.AddField(radioButton, new RectangleF(rc.Left, radioTop, radioSize, radioSize));
            _radioButtonCount++;

            // text for radio button field
            using (SolidBrush brush = new SolidBrush(Color.Black))
            {
                float x = rc.Left + radioSize + 1.0f;
                float y = rc.Top + (rc.Height - radioSize - 1.0f) / 2;
                _c1pdf.DrawString(text, new Font(font.Name, radioSize, font.Style), brush, new PointF(x, y));
            }

            // done
            return(radioButton);
        }
Example #4
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 = "FillForm.pdf";

            using (PdfDocument pdf = new PdfDocument(@"..\Sample data\form.pdf"))
            {
                foreach (PdfControl control in pdf.GetControls())
                {
                    switch (control.Name)
                    {
                    case "login":
                        ((PdfTextBox)control).Text = "Some Name";
                        break;

                    case "passwd":
                    case "passwd2":
                        PdfTextBox password = (PdfTextBox)control;
                        password.Text          = "Password";
                        password.PasswordField = true;
                        break;

                    case "email":
                        ((PdfTextBox)control).Text = "*****@*****.**";
                        break;

                    case "user_viewemail":
                        ((PdfCheckBox)control).Checked = false;
                        break;

                    case "user_sorttopics":
                        // Check the radio button "Show new topics first"
                        PdfRadioButton sortTopics = (PdfRadioButton)control;
                        if (sortTopics.ExportValue == "user_not_sorttopics")
                        {
                            sortTopics.Checked = true;
                        }

                        break;

                    case "BtnRegister":
                        ((PdfButton)control).ReadOnly = true;
                        break;
                    }
                }

                pdf.Save(pathToFile);
            }

            Console.WriteLine($"The output is located in {Environment.CurrentDirectory}");
        }
        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 = "SubmitResetFormActions.pdf";

            using (PdfDocument pdf = new PdfDocument())
            {
                PdfPage    page    = pdf.Pages[0];
                PdfTextBox textBox = page.AddTextBox("sample_textbox", 10, 50, 100, 15);
                textBox.Text = "Hello";

                PdfCheckBox checkBox = page.AddCheckBox("sample_checkbox", 10, 70, 100, 15, "Check me");
                checkBox.Checked = true;

                PdfRadioButton radioButton = page.AddRadioButton("radio", 10, 90, 100, 15, "Select me!");
                radioButton.ExportValue = "radio1";
                radioButton.Checked     = true;

                PdfRadioButton radioButton2 = page.AddRadioButton("radio", 10, 110, 100, 15, "No, select me!");
                radioButton2.ExportValue = "radio2";
                radioButton2.Checked     = false;

                PdfButton submitButton = page.AddButton(10, 130, 45, 20);
                submitButton.Text = "Submit";
                PdfSubmitFormAction submitAction = pdf.CreateSubmitFormAction(new Uri("http://bitmiracle.com/login.php"));
                submitAction.SubmitFormat = PdfSubmitFormat.Html;
                submitAction.SubmitMethod = PdfSubmitMethod.Get;
                submitAction.AddControl(textBox);
                submitAction.AddControl(checkBox);
                submitAction.AddControl(radioButton);
                submitAction.AddControl(radioButton2);
                submitButton.OnMouseDown = submitAction;

                PdfButton resetButton = page.AddButton(65, 130, 45, 20);
                resetButton.Text = "Reset";
                PdfResetFormAction resetAction = pdf.CreateResetFormAction();
                resetAction.AddControl(textBox);
                resetAction.AddControl(checkBox);
                resetAction.AddControl(radioButton);
                resetAction.AddControl(radioButton2);
                resetButton.OnMouseDown = resetAction;

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
        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 fdfFile = "ExportFdfData.fdf";

            using (PdfDocument pdf = new PdfDocument(@"..\Sample Data\form.pdf"))
            {
                foreach (PdfControl control in pdf.GetControls())
                {
                    switch (control.Name)
                    {
                    case "login":
                        ((PdfTextBox)control).Text = "Some Name";
                        break;

                    case "email":
                        ((PdfTextBox)control).Text = "*****@*****.**";
                        break;

                    case "user_viewemail":
                        ((PdfCheckBox)control).Checked = false;
                        break;

                    case "user_sorttopics":
                        // Check the radio button "Show new topics first"
                        PdfRadioButton sortTopics = (PdfRadioButton)control;
                        if (sortTopics.ExportValue == "user_not_sorttopics")
                        {
                            sortTopics.Checked = true;
                        }

                        break;
                    }
                }

                pdf.ExportFdf(fdfFile);
            }

            Console.WriteLine("FDF file is exported to " + Path.Combine(Directory.GetCurrentDirectory(), fdfFile));
        }
Example #7
0
        // add radio button box field for fields of the PDF document
        // with common parameters and default names.
        //  
        internal PdfRadioButton RenderRadioButton(bool value, string group, string text, Font font, RectangleF rc, Color back, string toolTip)
        {
            // create
            string name = string.IsNullOrEmpty(group) ? "ACFRGR" : group;
            PdfRadioButton radioButton = new PdfRadioButton();

            // parameters
            radioButton.Name = name;
            radioButton.DefaultValue = value;
            radioButton.Value = value;
            radioButton.ToolTip = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Color.Transparent && !back.IsEmpty)
            {
                radioButton.BackColor = back;
            }

            // add
            float radioSize = font.Size;
            float radioTop = rc.Top + (rc.Height - radioSize) / 2;
            _c1pdf.AddField(radioButton, new RectangleF(rc.Left, radioTop, radioSize, radioSize));
            _radioButtonCount++;

            // text for radio button field
            using (SolidBrush brush = new SolidBrush(Color.Black))
            {
                float x = rc.Left + radioSize + 1.0f;
                float y = rc.Top + (rc.Height - radioSize - 1.0f) / 2;
                _c1pdf.DrawString(text, new Font(font.Name, radioSize, font.Style), brush, new PointF(x, y));
            }

            // done
            return radioButton;
        }