Print Page | Close Window

Create & fill Checkboxes and Radiobuttons in code

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2337
Printed Date: 22 Nov 24 at 6:17PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Create & fill Checkboxes and Radiobuttons in code
Posted By: AndrewC
Subject: Create & fill Checkboxes and Radiobuttons in code
Date Posted: 17 Jul 12 at 3:29PM

Here is some simple code to create 2 checkboxes and 2 radio buttons.  The radio buttons are grouped together and the QP.SetFormFieldValue function is used to fill the field with a value.

Andrew.

            QP.SetOrigin(1);

            int y = 50;

            QP.SetTextSize(16);
            QP.DrawText(50, y - 10, "Check Boxes");

            int c1 = QP.NewFormField("Check1", 3);    // Type = Checkbox
            QP.SetFormFieldBounds(c1, 50, y, 20, 20);
            QP.SetFormFieldCheckStyle(c1, 1, 1);        // Style = Check, Centred 
            QP.SetFormFieldValue(c1, "Off");

            int c2 = QP.NewFormField("Check2", 3);
            QP.SetFormFieldBounds(c2, 90, y, 20, 20);
            QP.SetFormFieldCheckStyle(c2, 1, 1);       // Style = Check, Centred 
            QP.SetFormFieldValue(c2, "Yes");

            y += 80;
            QP.DrawText(50, y - 10, "Radio Buttons");

            int r0 = QP.NewFormField("RadioParent", 4);  // Type = Radiobutton

            int r1 = QP.AddFormFieldSub(r0, "Radio1");
            QP.SetFormFieldBounds(r1, 50, y, 20, 20);
            QP.SetFormFieldCheckStyle(r1, 2, 1);   // Radio, Centred

            int r2 = QP.AddFormFieldSub(r0, "Radio2");
            QP.SetFormFieldBounds(r2, 90, y, 20, 20);
            QP.SetFormFieldCheckStyle(r2, 2, 1);   // Radio, Centred

            QP.SetFormFieldValue(r0, "Radio2");

            QP.SaveToFile("out.pdf");




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk