Wednesday, January 21, 2009

Simple Human Verification

While doing some work that involved contacting webmasters to have them update information regarding our office, I ran across an innovative but simple approach to human verification.

In web form submissions, developers would like to avoid having spam bots from sending in thousands of forms with junk info, so they typically use a randomly generated graphic that humans can read (sometimes) and computers can't (yet).

This form is used by Michigan simply asks the user to do a simple math problem and type the answer in a form field.  Simple yet effective (for now).

Tuesday, January 06, 2009

Editing PDF's

We have several online forms in PDF format.  Since I did not create the forms, I don't know if the source documents even exist.

I had to make some revisions today, and remembered how much I hate dealing with Adobe when it comes to modifying Pre-existing files.

You have to use the touchup text tool (found under tools-advanced Editing) to change the text, the touchup object tool to move around the text boxes and other objects, and to move form fields, you have to click on forms, then 'edit form in acrobat'.

All well and good.  But, Acrobat had grouped several text items together in the same text box.  I needed to move them separately.  After searching fruitlessly online, I discovered thatI can hold down the controlkey and then draw a box around the item I needed to separate from the text box.


Tuesday, November 25, 2008

Fun with Recursion

I needed to backup a subdirectory and need to go through all subdirectories under it.

I used recursion to solve the problem.  

For those who don't know, recursion is when a function calls itself to solve a problem.  The classic example is factorial.  5 Factorial is 5*4*3*2*1.  here's a function to do that
Function Factorial (number as integer) as long
if number=1 then
return 1
        else
return factorial (number-1)*number
end if
end function

Run through the code

Friday, November 14, 2008

Goofy Error and Cool library

Goofy Error
While working on a VB 2005 application (backup application to do multi-generational backups of critical files), I got a rather strange error. The error was 
"The item "obj\Debug\BackupConfig.BackupJobForm.resources" was specified more than once in the "Resources" parameter.  Duplicate items are not supported by the "Resources" parameter. BackupConfig"

I did a little googling, and tried to delete the obj folder under the application.  It did nothing.

I wound up having to delete the form and start over again.  I think it had to do with the form being saved as "FORM1" and then renamed to "BACKUPJOBFORM".  I think that the dependent files (aka the. resx and the .designer files) somehow got corrupted.
Library
I ran across an cool open source library that encapsulates zip file compression for dot net apps.  
Here is the link for some example code (VB of course). 

Wednesday, November 12, 2008

Lessons From Adobe Livecycle Designer

Today I was using Adobe's Livecycle Designer to create a fillable PDF form.  Livecycle is Adobe's fillable form creation utility that comes as a part of Acrobat Pro.

To be honest, I think that program is cumbersome and difficult to use.

Anyway, here's some lessions learned.

1.  Try to have Adobe find the fields
Typically, you'll create your form in Word or Publisher and then import into Adobe.  If use use Adobe Acrobat Pro first, instead of Livecycle, it has a built-in find form fields features that's handy.  It will look at your form, and try to guess where the fields go.  It gets things wrong all the time., but running this first will save you time. 

2.   When working in Livecycle, save often
I've lost several forms because Livecycle died.  Save early and often to save time and effort.  My main problem were malformed javascripts.  Adobe should be able to throw an execption saying "you're scripts are screwy" instead of crashing.

3.  When adding different Radio Button Groups.
Creating one group is easy.  The second is where it gets hard.  The easiest way I found to cre
ate seperate radio button groups (a group is
 a collection of radio buttons that are mutually exclusive, turning on one, turns the others off) is 
  1. Drag the new radio button to the form
  2. right click on the button 
  3. Click on "Wrap in New Radio Button Group" (see figure)
  4. You're done
Validation
There are times you would like to advise your users that the values they entered are inccrrect.  There are really good reasons to do so.

First, you put a form out to collect data from users.   If they have made a mistake, they will be able to correct it and put the correct information into the form.  Once the form is received, all you can do is guess or attempt to contact the user for clairfication.  It makes sense to do the editing before you receive the form.  Second, there are some values that are simply wrong.  A data of 2/30/xxxx is always wrong.  If they entered this date, did they mean 1/30 or 3/30?

Be careful with edits, though.  You must allow for unknown values, even if it doesn't make sense to you (for example, on gender), but its better than making the user lie in order to submit the form.


To do edits, place the validation code into the validation script in livecyle.  Below are two examples of validation code.

Livecycle desginer 8
//Validate days in the month based upon month(1 <= this.rawValue && this.rawValue <=29 && MonthField.rawValue ==2) || (1 <= this.rawValue
 &&
 this.rawValue <=30 && (MonthField.rawValue ==4 || MonthField.rawValue ==6 || MonthField.rawValue ==9 || MonthField.rawValue ==11)) || (1 <= this.rawValue && this.rawValue <=31 && (MonthField.rawValue ==1 || MonthField.rawValue ==3 || MonthField.rawValue ==7 || MonthField.rawValue ==8 || MonthField.rawValue ==10 || MonthField.rawValue ==12));
 
 
//Validate the year
var dt = new Date();
var cyr = dt.getFullYear();
1917 <= this.rawValue && this.rawValue <=parseInt(cyr);
Creating Radio Button Groups