How do I proerly set value on radio and check boxes when filling PDF forms?

Q: I developed a ASP.NET web service that fills in a PDF form template
with form data.

Everything is working great but I run into an issue with Check boxes
sometimes not appearing when checked using the following code:

using System;
using System.Collections;
using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Text;
using pdftron.Filters;
using pdftron.PDF;
using pdftron.SDF;
using pdftron;

public partial class Home : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
        string myFile = Server.MapPath("checkbox.pdf");
        byte[] larr_FileContents = File.ReadAllBytes(myFile);
        int lint_BuffSize = 0;
        using (PDFDoc pdfDocument = new PDFDoc(larr_FileContents,
            WriteFormDataToPdf("CheckBox2", "True", pdfDocument);
            WriteFormDataToPdf("CheckBox3", "True", pdfDocument);
            larr_FileContents = null;
            pdfDocument.Save("C:\\Temp\\apptest" +
Guid.NewGuid().ToString() + ".pdf",
            pdfDocument.Save(ref larr_FileContents, ref lint_BuffSize,

private bool WriteFormDataToPdf(string fieldName, string fieldValue,
PDFDoc pdfDocument)
        // Set field value in pdf
        FieldIterator fieldIterator =
        Field currentField = fieldIterator.Current();

        if (currentField != null)
currentField.SetFlag(pdftron.PDF.Field.Flag.e_read_only, true);
            return true;
        throw new Exception("Unable set value '" + fieldValue + "' for
the field '" +
            fieldName + "'");
    return false;

A: The problem is that you are setting the check box field value using
SetValue("True") instead of SetValue(true). The former version selects
the explicirtly provided appearance for the checkbox, but in your PDF
there is no such appearance (there is only "Yes" and "Off"
appearance). In most cases it is better to set the radio and check box
fields using field.SetValue(bool) instead of using an explicit