Print Page | Close Window

RadioButtons

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=782
Printed Date: 17 May 24 at 1:26PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: RadioButtons
Posted By: ice_bora
Subject: RadioButtons
Date Posted: 10 Sep 07 at 6:25AM
I've moved it to this more suitable section ;-)    Ingo

Hi all.

I have sample code.
  1.Create output.pdf file with 2 - checkbox and 3 - radiobutton.
  2. Read output.pdf file, select checkboxes and try select radiobutton
      and save new file. But in new outputres.pdf file checkboxes are    
      checked but radiobuttons empty.

I can't select radiobutton !!!! 

1) Create pdf file.

.....
spPDF->UnlockKey("---")
......

spPDF->NewDocument();
spPDF->SetMeasurementUnits(1);
spPDF->SetOrigin(1);
spPDF->SetPageSize(_T("A4"));


long NormalFont = spPDF->AddStandardFont(4);
long BoldFont = spPDF->AddStandardFont(5);
long FieldIndex  = 0;
long SubIndex    = 0;


spPDF->SelectFont(BoldFont);
spPDF->SetTextSize(10);
spPDF->DrawTextBox(20,20,100, 5, "Which of these fruit do you like?", 0);

spPDF->SelectFont(NormalFont);
spPDF->SetTextSize(10);
spPDF->DrawTextBox(27, 30, 55, 5, "Orange", 0);

FieldIndex = spPDF->NewFormField("LikeOrange", 3);
spPDF->SetNeedAppearances(0);
spPDF->SetFormFieldBounds(FieldIndex, 20, 30, 60, 5);
spPDF->SetFormFieldCheckStyle(FieldIndex, 3, 0);

spPDF->DrawTextBox(27, 40, 55, 5, "Peach", 0);
FieldIndex = spPDF->NewFormField("LikePeach", 3);
spPDF->SetFormFieldBounds(FieldIndex, 20, 40, 60, 5);
spPDF->SetFormFieldCheckStyle(FieldIndex, 3, 0);



spPDF->SelectFont(BoldFont);
spPDF->SetTextSize(10);
spPDF->DrawTextBox(20, 60, 100, 5, "Which is your favourite fruit?", 0);

FieldIndex = spPDF->NewFormField("FruitChoice", 4);

SubIndex = spPDF->AddFormFieldSub(FieldIndex, "Banana");
spPDF->DrawTextBox(27, 70, 55, 5,"Banana", 0);
spPDF->SetFormFieldBounds(SubIndex, 20, 70, 60, 5);
spPDF->SetFormFieldCheckStyle(SubIndex, 4, 0);

SubIndex = spPDF->AddFormFieldSub(FieldIndex, "Apple");
spPDF->DrawTextBox(27, 80, 55, 5,"Appleeee", 0);
spPDF->SetFormFieldBounds(SubIndex, 20, 80, 60, 5);
spPDF->SetFormFieldCheckStyle(SubIndex, 4, 0);

SubIndex = spPDF->AddFormFieldSub(FieldIndex, "Grapes");
spPDF->DrawTextBox(27, 90, 55, 5,"Grapes", 0);
spPDF->SetFormFieldBounds(SubIndex, 20, 90, 60, 5);
spPDF->SetFormFieldCheckStyle(SubIndex, 4, 0);

hr= spPDF->SaveToFile("C:\\output.pdf");//save the file to disk



2).  Read file and  mark  checkbox as checked (work)
     and try select radiobutton.

........

spPDF->LoadFromFile("C:\\output.pdf");//load a local file

long s = spPDF->FormFieldCount();
for (int index=1; index<=s; index++)
{
    long type = spPDF->GetFormFieldType(index);

    if (type == 3) // checkbox
    {
        _bstr_t val = spPDF->GetFormFieldValue(index);
        spPDF->SetFormFieldValue(index, "Yes");
    }

    if (type == 4) // radiobutton
    {
        long chd = spPDF->GetFormFieldSubCount(index);
        long chd2 = spPDF->GetFormFieldKidCount(index);

        for (int i=1; i<=chd2; i++)
        {
            _bstr_t sub_name = spPDF->GetFormFieldSubName(index,i);
            long subindex = spPDF->GetFormFieldSubTempIndex(index,i);
            long chd3 = spPDF->GetFormFieldKidCount(subindex);
            long sub_type = spPDF->GetFormFieldType(subindex);
            spPDF->SetFormFieldValue(subindex, "Yes");
        }

    }
}
spPDF->SaveToFile("C:\\output_result.pdf");//save the file to disk




Replies:
Posted By: ice_bora
Date Posted: 12 Sep 07 at 5:54AM
Hi.
I can't select radiobutton.
Search in all forums, read reference guide and can't find !!!!
Help me somebody.



Posted By: ice_bora
Date Posted: 12 Sep 07 at 6:42AM
Hi again.

Maybe it doesn't work and I try do impossible.


Posted By: Ingo
Date Posted: 12 Sep 07 at 7:24AM
Hi!

Only an idea how to go on ...
You're calling the functions... get the resulting values... and working with these values. Perhaps it's better to check the returning values first - so you know where the first error appears.

Good luck,
Ingo



Posted By: ice_bora
Date Posted: 26 Sep 07 at 5:43AM
Hi.

I had holiday and now return to radiobuttons again.

1. I have field with type radiobutton (type = 4) and 3 subfields in this field.
2. long chld  = spPDF->GetFormFieldKidCount(indexField);
    get child count = 3;
3. for (long i =1; i<=chld; i++)
    {
       long subindex   = spPDF->GetFormFieldSubTempIndex(indexField, i);
       _bstr_t subName = spPDF->GetFormFieldSubName(indexField, i);
       long typeSub    = spPDF->GetFormFieldType(subindex);  
    }
   subindex is like us 1426064130 number.
   typeSub = 4 - radiobutton too.

   First subName is "Off" why ? What is the subField ?
   And next are correct names but needs use chld+1 for get last field ?

I can change  text, style for subFields.
       spPDF->SetFormFieldCheckStyle(subindex, 1, 0);

But I can't do select for one subField !!!!!
    long res = spPDF->SetFormFieldValue(subindex, "Yes");

Who did something like, help me please.

Pasha.


Posted By: ice_bora
Date Posted: 26 Sep 07 at 5:48AM
Hi Ingo.

I check return values.
But subfield doesn't  has value, title and when I setValue return result 0.

May be needs use iSEDQuickPDF.dll but problem with registration dll.
I use iSED.dll for VC++.
It's correct ?


Pasha.


Posted By: ice_bora
Date Posted: 27 Sep 07 at 6:39AM
Hi all.

My monologue continuing ))).

Needs set default value to the field, value is one from subfields.
spPDF->setFormFieldDefaultValue(indexField, "one from subfields)";

Pasha.


Posted By: marian_pascalau
Date Posted: 28 Sep 07 at 2:51AM

Hi there, send a small program + PDF to support(at)quickpdf.org and I will take a look on your problem.

And of course that with program I mean source code. C++, Delphi, C#, VB.NET are ok for me.
 
Best regards, Marian



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk