Sorry, I'm not sure which extra parameter you're referring to. By
createCheck() do you mean the method that created the parent field or that
creates the kid field? If it's the latter, iTextSharp doesn't have methods
like that, instead you have lines like PdfFormField field =
checkbox.RadioField; (RadioField being a property of the RadioCheckField
class, or possibly it's base class, I'm not sure, but it's a property, and
not a method, and thus I have no way of changing how it behaves short of
extending the iTextSharp class and overriding it, which seems rather
excessive for this).
As for the parent's behaviour, you said that the CreateRadioButton() method
only creates the appearance, so how would I change the options of the parent
field itself? Right now, the kid fields are being added to the PdfFormField
which is initialized to whatever CreateRadioButton() returns, so I would
assume that that PdfFormField is the parent, but I can't set any related
(checkbox/radiogroup specific) options on it (at least not in any way I can
tell).
On 12 April 2011 14:53, Mark Storer <msto...@autonomy.com> wrote:
> Ah.
>
> Okay, then just drop the extra parameter in the createCheck() call (or
> change it to false, same results). The kids were inheriting the parent's
> behavior. And don't set the kid's option either.
>
> Final Point: If you're using some Off Brand PDF viewer, they may not have
> implemented the "toggle to off" behavior in the first place (or they have a
> bug).
>
> --Mark Storer
> Senior Software Engineer
> Cardiff.com
>
> import legalese.Disclaimer;
> Disclaimer<Cardiff> DisCard = null;
>
>
>
> ------------------------------
> *From:* André Lemay [mailto:lemay.an...@gmail.com]
> *Sent:* Tuesday, April 12, 2011 11:40 AM
> *To:* Post all your questions about iText here
> *Subject:* Re: [iText-questions] iTextSharp RadioGroup noToggleToOff
> notworking.
>
> Thanks for the reply, but I think one of us of misunderstanding something..
>
> checkbox.Option |= PdfFormField.FF_NO_TOGGLE_TO_OFF; looks to me like that
> would set the checkboxes to NOT be uncheckable. This is the behaviour that I
> want to remove, i.e. I want the checkboxes to be uncheckable, so that their
> behaviour would be something like this :
>
> given checkboxes A and B, both starting unchecked, click A->A is checked,
> click B->A is unchecked and B is checked, click B->B is unchecked.
>
> If it helps at all, here's a simplified example that should be runnable on
> it's own (note that as it's iTextSharp, it would need to be changed a bit to
> work in Java with plain old iText) :
>
>
> Document document = new Document();
> PdfWriter writer = PdfWriter.GetInstance(document, new
> FileStream(@"C:\Users\Andre\Desktop\testpdf.pdf", FileMode.Create));
> document.Open();
>
> PdfContentByte canvas = writer.DirectContent;
> Rectangle rect = new Rectangle(100, 100, 110, 110);
> PdfFormField field;
> PdfFormField radiogroup =
> PdfFormField.CreateRadioButton(writer, false);
> radiogroup.FieldName = "language";
> RadioCheckField checkbox = new RadioCheckField(writer, rect,
> "check1", "on_check1");
> checkbox.Options |= PdfFormField.FF_NO_TOGGLE_TO_OFF;
> field = checkbox.RadioField;
> radiogroup.AddKid(field);
>
> rect = new Rectangle(120, 100, 130, 110);
> checkbox = new RadioCheckField(writer, rect, "check2",
> "on_check2");
> checkbox.Options |= PdfFormField.
> field = checkbox.RadioField;
> radiogroup.AddKid(field);
>
> writer.AddAnnotation(radiogroup);
> document.Close();
>
> On 12 April 2011 14:24, Mark Storer <msto...@autonomy.com> wrote:
>
>> Took me a couple readings of the code to figure this one out myself.
>>
>> CreateRadioButton creates the visual element for a radio button field, not
>> the parent field under which the kids reside. The "no toggle off"
>> behavior should be in the individual child fields, not the parent.
>>
>> The parent field is working, so that's clearly not a big deal. And to fix
>> your button creation code, you need to add:
>>
>> checkBox.options |= PdfFormField.FF_NO_TOGGLE_TO_OFF;
>>
>> No that isn't one of the listed options in BaseField's JavaDoc. The full
>> list of valid options are all the PdfFormField.FF_* contstants, some of
>> which are duplicated in BaseField without the leading FF_.
>>
>> --Mark Storer
>> Senior Software Engineer
>> Cardiff.com
>>
>> import legalese.Disclaimer;
>> Disclaimer<Cardiff> DisCard = null;
>>
>>
>>
>> ------------------------------
>> *From:* André Lemay [mailto:lemay.an...@gmail.com]
>> *Sent:* Tuesday, April 12, 2011 8:54 AM
>> *To:* itext-questions@lists.sourceforge.net
>> *Subject:* [iText-questions] iTextSharp RadioGroup noToggleToOff not
>> working.
>>
>> Here are the bits of code in question :
>>
>> [code]
>> PdfFormField group1 = PdfFormField.CreateRadioButton(writer, false);
>> group1.FieldName = "group1";
>> group1.AddKid(CreateCheckBox(over, "check1", 8.5f, 363, 459.8f
>> + GIFLOffset_1, 0.3f));
>> group1.AddKid(CreateCheckBox(over, "check2", 8.5f, 471, 459.8f
>> + GIFLOffset_1, 0.3f));
>> writer.AddAnnotation(group1);[/code]
>>
>> and the CreateCheckBox method :
>> [code]
>> private static PdfFormField CreateCheckBox(PdfContentByte layer, String
>> name, float size, float llx, float lly, float thickness)
>> {
>> PdfFormField field;
>> RadioCheckField checkbox;
>> Rectangle rect = new Rectangle(llx, lly, llx + size, lly +
>> size);
>> checkbox = new RadioCheckField(layer.PdfWriter, rect, name,
>> "on_" + name);
>> checkbox.CheckType = RadioCheckField.TYPE_CHECK;
>> checkbox.BackgroundColor = BaseColor.WHITE;
>> checkbox.BorderColor = BaseColor.BLACK;
>> checkbox.BorderStyle = PdfBorderDictionary.STYLE_SOLID;
>> checkbox.BorderWidth = 0.4f;
>> checkbox.FieldName = name;
>> field = checkbox.RadioField;
>> layer.Rectangle(rect);
>> layer.SetLineWidth(0.4f);
>> layer.Stroke();
>> return field;
>> }[/code]
>>
>> This code is part of a larger program that generates a customized
>> document. The checkboxes are created fine and show up properly, and I can
>> check one or the other (but not both) as expected, however they cannot be
>> unchecked at all.
>>
>> I was under the impression that the false value passed into the
>> CreateRadioButton method should make it so that you can uncheck a box so
>> that neither will be checked, but even changing that to true had no effect
>> on behaviour (that behaviour being that once one of the checkboxes is
>> checked, one will always be checked unless a reset button elsewhere on the
>> form is clicked).
>>
>> Any help getting the checkboxes to be uncheckable would be greatly
>> appreciated.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Forrester Wave Report - Recovery time is now measured in hours and minutes
>> not days. Key insights are discussed in the 2010 Forrester Wave Report as
>> part of an in-depth evaluation of disaster recovery service providers.
>> Forrester found the best-in-class provider in terms of services and
>> vision.
>> Read this report now! http://p.sf.net/sfu/ibm-webcastpromo
>> _______________________________________________
>> iText-questions mailing list
>> iText-questions@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> iText(R) is a registered trademark of 1T3XT BVBA.
>> Many questions posted to this list can (and will) be answered with a
>> reference to the iText book: http://www.itextpdf.com/book/
>> Please check the keywords list before you ask for examples:
>> http://itextpdf.com/themes/keywords.php
>>
>
>
>
> ------------------------------------------------------------------------------
> Forrester Wave Report - Recovery time is now measured in hours and minutes
> not days. Key insights are discussed in the 2010 Forrester Wave Report as
> part of an in-depth evaluation of disaster recovery service providers.
> Forrester found the best-in-class provider in terms of services and vision.
> Read this report now! http://p.sf.net/sfu/ibm-webcastpromo
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now! http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php