I already have it working with RadioCheckField. It's much better than how I was
doing it. Thanks for the help.
Bruce
From: Mark Storer [mailto:[email protected]]
Sent: Wednesday, April 14, 2010 2:17 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Checkbox not displaying "checkmark" whenselected.
I did notice one little problem. The On and Off appearances are virtually
identical. If you want to see a check mark, you need to draw it. Again,
RadioCheckField does it for you.
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: Bruce Tompkinson [mailto:[email protected]]
Sent: Wednesday, April 14, 2010 1:19 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Checkbox not displaying "checkmark" whenselected.
Thanks, I had not seen the RadioCheckField class yet. I will look into it. I
have attached the output PDF. I get the same results with RadioButtons using
basically the same code.
Bruce
From: Mark Storer [mailto:[email protected]]
Sent: Wednesday, April 14, 2010 12:14 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Checkbox not displaying "check mark"
whenselected.
Just looking at your code, it looks OK.
Two things.
1) The RadioCheckField class does all this for you. I strongly recommend you
use it instead.
2) Can we see your PDF?
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: Bruce Tompkinson [mailto:[email protected]]
Sent: Wednesday, April 14, 2010 9:54 AM
To: [email protected]
Subject: [iText-questions] Checkbox not displaying "check mark" whenselected.
Hello,
I am attempting to add a check box to my PDF using iTextSharp and the following
code:
PdfFormField field = PdfFormField.CreateCheckBox(m_PDFWriter);
Rectangle box = new Rectangle(m_CurrentX,
m_CurrentY,
m_CurrentX + Width,
m_CurrentY + Width);
field.SetWidget(box, PdfAnnotation.HIGHLIGHT_INVERT);
field.Flags = PdfAnnotation.FLAGS_PRINT;
field.FieldName = FieldName;
field.ValueAsName = Value ? "On" : "Off";
field.AppearanceState = Value ? "On" : "Off";
field.MKBorderColor = m_ForeColor;
field.MKBackgroundColor = m_FillColor;
PdfAppearance onApp = PdfAppearance.CreateAppearance(m_PDFWriter, Width, Width);
onApp.SetFontAndSize(m_Font.BaseFont, m_FontSize);
onApp.SetColorFill(m_FillColor);
onApp.SetColorStroke(m_ForeColor);
onApp.Rectangle(0, 0, Width, Width);
onApp.FillStroke();
PdfAppearance offApp = PdfAppearance.CreateAppearance(m_PDFWriter, Width,
Width);
offApp.SetFontAndSize(m_Font.BaseFont, m_FontSize);
offApp.SetColorFill(m_FillColor);
offApp.SetColorStroke(m_ForeColor);
offApp.Rectangle(0, 0, Width - 1, Width - 1);
offApp.FillStroke();
PdfAppearance defaultApp = PdfAppearance.CreateAppearance(m_PDFWriter, Width,
Width);
defaultApp.SetFontAndSize(m_Font.BaseFont, m_FontSize);
defaultApp.SetColorFill(m_FillColor);
defaultApp.SetColorStroke(m_ForeColor);
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", onApp);
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", offApp);
field.DefaultAppearanceString = defaultApp;
m_PDFWriter.AddAnnotation(field);
The checkbox appears correctly whether or not it is on or off with the check
mark displayed correctly. When the checkbox is selected with the mouse the box
becomes completely filled with the fill color and the mark is not visible,
whether the next state is "On" or "Off". I almost looks like there is a pattern
that needs to be set for the rectangle that will display the checkmark when it
is filled.
Any pointers would be greatly appreciated. Thanks.
Bruce
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2806 - Release Date: 04/13/10
23:31:00
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2806 - Release Date: 04/13/10
23:31:00
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/