posts - 198,  comments - 1481,  trackbacks - 6
有人需要就贴了出来了,这个系列的100多个demo去年已经翻译完毕,一直想不出有什么必要放出来,搁置半年了。
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-05-02 09:22 RubyPDF 阅读(...) 评论(...) 编辑 收藏