Author Archive: Steve Tibbett

Flex 2 is Done!

This is very cool. Flex is the best way to create a rich Internet application. I love the Flex Builder IDE, and the fact that Flex’s MXML markup makes it really easy to create a rich UI with a lot of the interactivity that you have to work really hard to get out of AJAX, and with a responsiveness that you just cant get anywhere else.

It can seem like we have two products competing for the same sort of market, in that we have Form Designer and PDF forms, and then we have Flex Builder and RIA’s. But these are really two different things, and serve different purposes.

It comes down to the difference between a “Dynamic Document” and a “Rich Internet Appplication”.

With Flex, the focus is on the application. The application loads, and then maybe fetches some data, or maybe lets you create some data; but what matters is the application.

With PDF Forms, the document is the focus. You can sign the document, encrypt it, run validations on the data it contains, and so on, but it all revolves around the document.

You wouldn’t build a shopping cart with Form Designer, but you wouldn’t create an invoice with Flex. Each tool has its place.

There’s going to be some real power around the combination of these two.

Submit to PHP

A common request in the comments on the HTTP Submit post is how to retrieve the values from PHP, so I’ve created a simple sample just to demonstrate that clearly.

PHP Submit Sample

This sample has a couple of text fields which, when submitted using either of the buttons on the form, echoes the text back to you by the PHP code on the server. The server code is also included in the form.

Submit Format

I posted about what the data looks like when you submit a form using an HTTP Submit Button, but there are other ways of submitting forms.

I’ve created a Submit Comparison PDF that has a few fields on it, and buttons for the four different types of data submission that Acrobat supports.

These are: XDP, PDF, XML, and URL-encoded.

URL-encoded is what the HTTP Submit Button does; to use one of the other formats, drop a Button onto your form, set the Control Type to Submit, and then you can use the Submit tab on the Object Inspector to control how the data is submitted.

Submitting in XDP format gives you XML data that includes an xfa:data model, as well as an execEvent node that identifies which button the user pushed to submit the form. This provides the most data.

Submitting XML gives you the same data that you’d get if you emailed the filled out form data from Reader – it’s an XML packet with a chunk of friendly human-readable text that describes how to submit the data. The form data you get is the same as what you get with the XDP format, but without the xfa wrappers.

Try out the PDF file I linked above – the Submit button posts to my dump.php script so you can see what actually got submitted.

HTTP Submit

There are a number of different ways to submit a form, and which one is right depends on context. When your form is part of a workflow created with Adobe’s Workflow Server, you need to submit using the LiveCycle Workflow fields:

These ensure that the user has the controls they need for the state they’re at in the workflow.

Outside of Workflow, you can still create forms that integrate with server side processes. Form Designer and Reader support two methods for submitting data: submitting form data as application/x-www-form-urlencoded using HTTP POST, and SOAP. The former is what I’m talking about in this post.

When you create an HTML form, you add some HTML fields, and a URL to POST to as the <form> tag’s action. For example:

<form method="post" action="http://stevex.net/dump.php">
  <label>TextField1
  <input type="text" name="TextField1" />
  </label>
</form>

I’ve created a simple PHP script that dumps out what you submit to it parsed (so you can see what variables PHP found in the submitted data) as well as the raw POST body. The script is here. Typing "hello" into the text field and submitting this form shows that the following data was sent to the action URL:

TextField1=hello

Simple enough. It gets more complicated when there are more fields or special characters need escaping; the exact details of how that works are spelled out in the HTML 4.01 spec section 17.13.4 which covers application/x-www-form-urlencoded encoding, the MIME type that form data is submitted with.

So that’s how HTML submit works. What happens when you create a form with Form Designer and want to submit it using HTTP?

Here’s how to create a form equivalent to that little HTML form described above.

  1. Create a new form.
  2. Add some fields.
  3. Drop an HTTP Submit Button from the Library.
  4. Configure the HTTP Submit Button.

After step 3, you’ll have a Submit button on the form, with a wee yellow marker. Hover the mouse over the marker and you’ll see this message:

This handy reminder just lets you know that you need to click on the Submit button and in the Object Inspector, set the URL that the form will be posted to to something. (I don’t know about you but when creating HTML forms I’ve forgotten to enter the action URL more than once).

Designer’s preview is actually an embedded Internet Exporer, with a temporary PDF rendering of your form loaded into it. This means clicking the Submit button in the preview window will submit your form and you can see the results of the submit right in Designer.

Submitting from Acrobat is a bit more involved because Acrobat can’t display the HTML response directoy, but what happens is actually pretty cool. The HTTP submit happens, and the resulting HTML is captured by Acrobat and converted into a PDF, so you see the dump response page, but you see it in Acrobat as a PDF.

There are some limitations that come with submitting form data as HTTP. Because HTML forms aren’t hierarchial, any hierarchy in your own form is lost – for example, nesting fields within subforms will cause them to not appear in the submitted data. These limitations are mentioned in Designer’s documentation.

I’ve attached my sample HTTP Submit PDF form
so you can have a look at a few different field types and how they look in the submitted data.

So that covers HTTP submit. You can do a lot more with SOAP than just submit data, but that’s another story.

 

For(u)m Designer

A few members of the Form Designer development team (including myself and FormBuilder) have been hanging out on and trying to answer questions in the LiveCycle Designer forum. If you have any questions about forms or designing them, drop on by.

No Really, Scripting

I trust you’re back, and you’ve installed Designer. Welcome back.

If you haven’t got a Form Designer to install, you can find a free Tryout version over here.

All I wanted to mention today is one tip regarding scripting.

Often I fire up Designer to try something out, and today I was having trouble. I added a button to my form, added a text field, and added some script that would run when the button was clicked. But when I previewed the form and clicked the button, nothing happened.

When I saved the form as an XDP file, however, and then previewed and clicked the button, it worked fine.

This was a new computer I was trying this on, and I’d forgotten an important setting. In the Options dialog, the first option on the first page of options is “Default file type for new forms”.

fileoptions.png

If this is set to the default of “Static PDF Form File”, then your scripts won’t run. If you plan to be doing any scripting in Designer, then set this to “Dynamic PDF Form File”.

The XFA forms that Designer creates don’t work in old versions of Acrobat Reader, which is why this option is off by default. But if you’re developing interactive forms, you’ll probably want your users using a recent version of Reader, and having this option set to static forms by default means whenever you create a new form, none of the scripts you’re writing will work until you actually save it to disk as an XDP file or interactive form.

Adobe Designer Scripting

I’m going to occasionally talk about Adobe’s Form Designer in this blog, because that’s what I work on.

Designer comes with Acrobat Professional, although it’s not installed by default. If you have Acrobat installed, and you don’t have Designer, go dig out your Acrobat disc and install it. I’ll wait here.

Hello, World

There are a significant number of blogs in the world (I’d guess, at least 25% of all blogs created) whose only post is some equivalent of a “Hello, World” post.

So here’s mine. Hi!

Difference is, of course, that I’ll be back.

(But that’s what they all say isn’t it? Stay tuned…)