PDF Mosaic: How to add CheckBox to PDF document


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code

 

This sample shows how to use checkboxes in your PDF document.

Use PDFCheckBox class to add a checkbox.

Use PDFCheckBox class to add a checkbox in PDF Mosaic
 

using PDFMosaic;
using System;
 
namespace CheckBoxes
{
    class CheckBoxes
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();
            PDFPage page = new PDFPage(PDFPaperFormat.A4);
 
            PDFCheckBox checkBox1 = new PDFCheckBox(10, 40, 20, 20, "checkBox1");
 
            PDFCheckBox checkBox2 = new PDFCheckBox(10, 70, 20, 20, "checkBox2");
            checkBox2.Checked = true;
 
            PDFCheckBox checkBox3 = new PDFCheckBox(10, 100, 20, 20, "checkBox3");
            checkBox3.Checked = true;
            checkBox3.ReadOnly = true;
 
            page.Annotations.Add(checkBox1);
            page.Annotations.Add(checkBox2);
            page.Annotations.Add(checkBox3);
 
            PDFFont fnt = new PDFFont(PDFStandardFont.Helvetica, 10);
            PDFBrush br = new PDFSolidBrush();
 
            page.Canvas.DrawString("Unchecked", fnt, br, 35, 45);
            page.Canvas.DrawString("Checked", fnt, br, 35, 75);
            page.Canvas.DrawString("Read-only check box", fnt, br, 35, 105);
 
            document.Pages.Add(page);
            document.Save("CheckBoxes.pdf", true);
        }
    }
}

 


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code