Form_radio: Example code of Early Access iText

Source: Internet
Author: User
Using System;
Using iTextSharp. text;
Using iTextSharp.text.pdf;
Using System. IO;
Public class form_radio
{


[STAThread]
Public static void Main (string [] args)
{
Document document = new Document (PageSize. A4, 50, 50, 50, 50 );
Try
{
// Creation of the different writers
Using writer = Using writer. GetInstance (document, new FileStream (@ "e: \ java \ form_radio.Pdf", FileMode. Create ));
Document. Open ();
Required contentbyte cb = writer. DirectContent;
Cb. MoveTo (0, 0 );
PdfFormField radio = PdfFormField. CreateRadioButton (writer, true );
Paiappearance tpOff = cb. CreateAppearance (20, 20 );
Export appearance tpOn = cb. CreateAppearance (20, 20 );

TpOff. Circle (10, 10, 9 );
TpOff. Stroke ();

TpOn. Circle (10, 10, 9 );
TpOn. Stroke ();
TpOn. Circle (10, 10, 3 );
TpOn. FillStroke ();

Radio. FieldName = ("CreditCard ");
Radio. ValueAsName = ("MasterCard ");

PdfFormField radio1 = PdfFormField. CreateEmpty (writer );
Radio1.SetWidget (new Rectangle (100,700,120,720), PdfAnnotation. HIGHLIGHT_INVERT );
Radio1.AppearanceState = ("MasterCard ");
Radio1.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "Off", tpOff );
Radio1.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "MasterCard", tpOn );
Radio. AddKid (radio1 );

PdfFormField radio2 = PdfFormField. CreateEmpty (writer );
Radio2.SetWidget (new Rectangle (100,660,120,680), PdfAnnotation. HIGHLIGHT_INVERT );
Radio2.AppearanceState = ("Off ");
Radio2.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "Off", tpOff );
Radio2.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "Visa", tpOn );
Radio. AddKid (radio2 );

PdfFormField radio3 = PdfFormField. CreateEmpty (writer );
Radio3.SetWidget (new Rectangle (100,620,120,640), PdfAnnotation. HIGHLIGHT_INVERT );
Radio3.AppearanceState = ("Off ");
Radio3.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "Off", tpOff );
Radio3.SetAppearance (PdfAnnotation. APPEARANCE_NORMAL, "American", tpOn );
Radio. AddKid (radio3 );

Writer. AddAnnotation (radio );
Document. Close ();
System. Console. Out. WriteLine ("FIM .");
}
Catch (System. Exception de)
{
System. Console. Error. WriteLine (de. Message );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.