using System;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
public class form_checkbox
{
    
    
    [STAThread]
    
public static void  Main(string[] args)
    {
        Document document 
= new Document(PageSize.A4, 50505050);
        
try
        {
            
// creation of the different writers
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"e:\java\form_checkbox.Pdf", FileMode.Create));
            
            document.Open();
            PdfContentByte cb 
= writer.DirectContent;
            cb.MoveTo(
00);
            PdfFormField field 
= PdfFormField.CreateCheckBox(writer);
            PdfAppearance tpOff 
= cb.CreateAppearance(2020);
            PdfAppearance tpOn 
= cb.CreateAppearance(2020);
            tpOff.Rectangle(
111818);
            tpOff.Stroke();
            
            tpOn.SetRGBColorFill(
255128128);
            tpOn.Rectangle(
111818);
            tpOn.FillStroke();
            tpOn.MoveTo(
11);
            tpOn.LineTo(
1919);
            tpOn.MoveTo(
119);
            tpOn.LineTo(
191);
            tpOn.Stroke();
            
            field.SetWidget(
new Rectangle(100700120720), PdfAnnotation.HIGHLIGHT_INVERT);
            field.FieldName
=("Urgent");
            field.ValueAsName
=("Off");
            field.AppearanceState
=("Off");
            field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, 
"Off", tpOff);
            field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, 
"On", tpOn);
            writer.AddAnnotation(field);
            document.Close();
            System.Console.Out.WriteLine(
"FIM.");
        }
        
catch (System.Exception de)
        {
            System.Console.Error.WriteLine(de.Message);
        }
    }
}
posted on 2006-07-21 10:54  RubyPDF  阅读(1584)  评论(0编辑  收藏  举报