PDF Forms and Javascript

Acrobat: Forms and Javascript

Don’t want to write CGI? Try this: Adobe Acrobat Reader and Forms Data without Custom CGI

Part 1: Insert into a database.

This note is largely based on the demonstration of Acrobat 5.0 Forms and Javascript I gave at the April 2001 Adobe PDF Days in India and South Asia.

The example Acrobat Forms Zipped FilesPDF and JavaScripts have been zipped here.

Creating the PDF

The first step is to create the base form. Here, the simple form is created in Microsoft Word 2000. Using the PDFMaker, covert the document into a PDF.

Adding the Form Fields

Adding the form fields is a matter of using the Form tool ( i[854] images/forms_tool.gif) to create four fields in the areas as indicated by the original Word areas.

Select form tool and drag out the form field filling to the area required.

You can copy and paste or ight click to copy, right click to paste to duplicate fields.

Double click on the field to edit the Field Properties. The scripts below nominate specific fields

[855] images/01_formfield.gif

Adding a Button

To create a button, use the same field tool as above and create it in the area required. Change the type to Button from the Type: popup menu.

[856] images/02_buttonfield.gif

In the Actions tab, select the Mouseup ‘when this happens…’ and click on the Add button. From the Type: popup, select ‘Javascript’

[857] images/03_javascript.gif

By clicking on the “Edit…” button you can insert the code into the Javascript section. This Javascript is executed when the ‘mouse goes up in the button’ – or in other words, when the mouse is clicked.

The Javascripts

// declare and fill local variables
var lAppName = this.getField("app.name").value;
var lAppAge = this.getField("app.age").value;
var lAppSkills = this.getField("app.skills").value;
var lAppYears = this.getField("app.years").value;

// save to ODBC database on local machine.
// this is named in Control Panels>Administrative Tools>Data Sources
var con = ADBC.newConnection("jobs");
var statement = con.newStatement();

//
var query = "INSERT INTO jobs ( name, age, skills, years) values ('" + lAppName + "','" + lAppAge + "','" + lAppSkills + "','" + lAppYears + "');";

// execute SQL statement on database
statement.execute(query);

Code example 1: Simple ODBC Insertion from a PDF form.

PlanetPDF on ADBC in Adobe PDF Forms

NB: Before this script will work, there needs to be an ODBC database source on your machine mapped to a database containing the table: ‘jobs’. This table will need at least 4 columns defined: ‘name’, ‘age’, ‘skills’ and ‘years’ I use Microsoft Access as my development database. Using Control Panels>Administrative Tools>Data Sources (ODBC) control panel, I have created an ODBC connection to the jobs.mdb file (Microsoft Access). This can be any ODBC datasouce.

[858] images/04_odbc.gif

var lAppName = this.getField("app.name").value;
var lAppAge = this.getField("app.age").value;
var lAppSkills = this.getField("app.skills").value;
var lAppYears = this.getField("app.years").value;

var lWeb = this.getField("web").value;

if (lWeb == "Yes") // we are submitting via a web server
{
var fieldsToSubmit = new Array("app.name","app.age","app.skills","app.years");
// change the http: URL to appropriate server name and/or address
this.submitForm("http://127.0.0.1/jobs.asp#FDF",true,false,fieldsToSubmit);
}
else
{
var con = ADBC.newConnection("jobs");
var statement = con.newStatement();
var query = "INSERT INTO jobs ( name, age, skills, years) values ('" + lAppName + "','" + lAppAge + "','" + lAppSkills + "','" + lAppYears + "');";
statement.execute(query);
}

Code example 2: Extending the example above, showing web submission alternative. The ASP referenced is in code example 3 below.

NB: This Javascript required the ASP in the next code example installed onto the server. The code above points to a server at “http://127.0.0.1/jobs.asp” This IP address is also known as the loopback address — its the same machine as the form is currently running on. Of course with real installations, this would point to a fully qualified domain name where the server-side script is residing. When sensitive information is involved, it is recommended to use a secure socket connection such as https://…

The Active Server Page (ASP)


<%Response.ContentType = "application/vnd.fdf"%>

<%

Set FdfAcx = Server.CreateObject("FdfApp.FdfApp")

Set FDF = FdfAcx.FDFCreate

Set FDFin = FdfAcx.FDFOpenFromBuf (Request.BinaryRead(Request.TotalBytes))

lName = FDFin.FDFGetValue("app.name")

lAge=FDFin.FDFGetValue("app.age")

lYears=FDFin.FDFGetValue("app.years")

lSkills=FDFin.FDFGetValue("app.skills")

set jobsConnection = Server.CreateObject("ADODB.Connection")

jobsConnection.Mode = adModeReadWrite

jobsConnection.Open "jobs"

set jobsRecordSet = Server.CreateObject("ADODB.RecordSet")

jobsRecordSet.LockType = 3

jobsRecordSet.Open "jobs",jobsConnection

jobsRecordSet.AddNew

jobsRecordSet.Fields("name") = lName

jobsRecordSet.Fields("age") = lAge

jobsRecordSet.Fields("years") = lYears

jobsRecordSet.Fields("skills") = lSkills

jobsRecordSet.Update

jobsRecordSet.Close

Response.BinaryWrite FDF.FDFSaveToBuf

FDF.FDFClose

%>

Code example 3: Active Server Page (ASP) using VBScript inserting the fields the form submits in code example 2.

NB: this code example requires an ODBC connection defined named ‘jobs’ This points to a database that contains the table ‘jobs’ with fields ‘name’, ‘age’, ‘years’, ‘skills’

Also installed is the Adobe FDFTK – Forms Data Format ToolKit. The Windows installer is available here.

For More Information

The best resouces for PDF and developer related information is PlanetPDF. More specifically, there is an Indepth Guide here. A fundamental requirement on the server-side is the Adobe FDF Toolkit

Adobe Systems’ information on the Forms feature of Acrobat is here.

QuarkXpress, PDF, Trapping and Overprint

Overprinting & Trapping in Adobe PDF Quick Note

version 1.2

As Acrobat 5.0 has this new cool “Overprint Preview” feature. And as Barney Kassabian has prompted me, this raises the whole issue of QuarkXpress and overprints/trapping.

Over the last 2 years, I was under the impression that overprints were retained in composite Quark Postscript files. I was only partly correct, or a bit wrong. You choose. To clarify, I have been experimenting.

Overprinting in QuarkXpress 3.32 to Adobe PDF

If you save out of QuarkXpress 3.32 as an EPS, Quark keeps the overprinting settings (as set in the View>Trap Information palette). Distilling this with Acrobat Distiller 4.05 or 5 results in a PDF where the overprint is retained. New in Acrobat 5.0 – you can view this on screen.

[859] images/trap_01_qxp_trapping.gif

However, if you use the Adobe preferred method of “Printing” via AdobePS to the Distiller (Mac: Create Adobe PDF, PC: Acrobat Distiller printers) — the overprinting information is NOT retained in the Postscript.

If you are a Postscript jockey, you can see the simple command is just plain missing from the Printed .ps file:

[860] images/trap_02_2vers_ps.gif

What about QuarkXpress 4.x?

Thankfully, QuarkXpress 4.x exports the “stovp” Postscript command when printing. Other trapping details are NOT retained in the composite Postscript output.

T stovp‘ — set overprint on the next drawn object to true — in English. This particular command (stovp) is defined in both the EPS and the standard Postscript headers of a QuarkXpress 3.32 Postscript file; its a QuarkXpress specific command in their Postscript header. Its just that the Composite Postscript printed from Quark happens to be missing the appropriate overprint command.

If you are wise to the ways of Postscript, or willing to shoot off your own foot, you can insert this command into the Printed postscript file from the the EPS version and viola! you have overprinting in the Printed output. Be warned! This may result in a Postscript file that is no longer valid; it may not RIP; and the Distiller may ‘spit its cookies’ at you. You have been warned. Don’t try this at home. I am a trained professional. Your mileage may vary. Insert standard legal disclaimer here.

The good news in this is that overprint information IS LEFT in the EPS files; placed from Illustrator or Quark generated EPS.

So, what is the recommended workflow? Out of QuarkXpress 3.32, save each page as an EPS file. Place each of these EPS files BACK into a QuarkXpress document (or InDesign document ) and THEN follow the guidelines of Printing to the Distiller via AdobePS.

Please note: you should not nest EPS file inside EPS files inside EPS files. Why not? Each EPS saves a graphic state before srawing its contents; at least once. There is a limit of 15 of these in Postscript 3; and depending on the content in the EPS, the RIP may cause a ‘limitcheck’ Postscript error.

Also please note: When creating and Distilling EPS files from QuarkXpress, note that Quark does not embed the fonts. This restriction forces you to Distill on the creating machine. Otherwise, there is the risk that you create a PDF where the fonts are not embedded.

[861] images/trap_03_qxp_placeeps.gif

And the resulting PDF displayed in Acrobat 5.0 with Overprint Preview turned on:

[862] images/trap_03a_acro5_withoverprint.gif

Another method, albeit more prone to trouble, is taking the EPS files created above and Distilling these directly. The trouble that you might find in this method is that the Distillers “Default Page Size” is used, UNLESS you have “Resize Page and Center Artwork for EPS Files” checked in the Advanved Tab.

[863] images/trap_04_distiller_pagesize.gif

Evidendly, Quark’s Composite postscript output changed in QuarkXpress 4.0x — where the overprinting settings were retained. This is good news.

Trapping

In a slightly similar fashion, QuarkXpress only saves its choking/spreading information when it prints Separations (usually not the default PDF workflow) or if you export as a DCS file. Once you save as a DCS file, you have separated your work. The choking/spreading is not saved when you save as EPS.

How do you “recompose” the separated DCS file/separated QuarkXpress file into a composite PDF? Apart from using a Modern Prepress application like InDesign? Adobe InDesign: Prepress Techniques

Thankfully, CreoScitex have an Acrobat plugin called CreoScitex Seps2Comp You can download a trial version Windows and/or MacOS from their web site.

It takes a multiple page PDF and allows you to “recombine” them into a composite PDF. In theory, common elements will exist in exactly the same place across the different plates. Its a matter of then adding the images/graphics back together and generating a composite image on screen. To do this manually involves creating channels in a Photoshop file (one channel for each of C, M, Y and K) — but you are left with a purely bitmap image.

Here is a screen dump of Sep2Comp in action. Its just a simple matter of applying a certain ink to the page that contains that plate. In Pre-separated Postscript, there is a special command that details how the separation is composed; Seps2Comp reads this and automatically applies the appropriate plate to ink.

[864] images/trap_05_seps2comp.gif

And the final result

[865] images/trap_06_sep_vs_comp.gif

Also good news is that PageMaker 6.x and InDesign 1.x saves composite Postscript with Trapping & Overprinting by default. There is no need for all this jumpling through hoops and funny business.

This is a screen dump of Acrobat 5.0 showing the effect of trapping using the default settings. As many of these traps have been set to overprint – you can see the traps live on screen. Cool.

InDesign 2.0: Generating Composite, Trapped PDFs has more info on how to do with with InDesign 2.0.

[866] images/trap_07_indesign_trap.gif

Adobe’s Support site on Trapping:

Trapping in InDesign 1.x

Trapping in PageMaker 6x

Quark’s Support site has good overviews of Trapping and Overprinting:

Trapping Overview from Quark

Thanks to Shane Stanley for suggesting the nested EPS change; Barney Kassabian for prompting this research & supplying test files; Grant Gittus for running his experienced eyes over my comments.

Imageready Rollovers


Rollover Styles in ImageReady 3.0

ImageReady 3.0 comes with Photoshop 6.0. One of the new features is the ability to create Styles that include Rollover states.

There is a slight nuance, however. You must create the style from a Layer Based Slice.

This module is © 2000 Adobe Systems, Inc and cannot be reproduced without the written consent of the author.

1. Select the layer that you wish to create the slice over. In this instance, I have created a shape that encompasses the rollover. [867] images/01_start.jpg

2. Menu Layer>New Layer Based Slice

[868] images/02_newlayerslice.jpg

3. From the Rollover palette, create a new rollover state by clicking on the [869] images/new.gif button. [870] images/03_newrollover.jpg

4. Change the Layer Style for the new rollover state. I have used an inner shadow in this example.[871] images/layer-style.gif [872] images/04_addstyle.jpg

5. From the Styles palette, click on the new button.[869] images/new.gif Ensure that “Include Rollover States” is checked. [874] images/05_newstyle.jpg

6. Now the style is created, it is a simple matter of dragging this style over the other two layers where you wish to create the rollovers. [875] images/06_dragstyle.jpg

7. Now the three Layer based slices and rollover states are created. [876] images/07_dragstyle2.jpg

8. You may need to optimise your slices as layer based slices are automatically sized to fit the content of the layer. This sometimes leaves “fringing” table cells and images, increasing the complexity of your slice.

Just promote the layer based slices to user slices using the menu Slices>Promote to User Slice

This will allow you to change the slice sizes to get an optimal table and images.

[877] images/08_optimiseslice.jpg

1996


November 1996 Revelation 96 (Pioneered Internet and Intranet technology presentations for Apple’s customers)
October 1996 Sales Conference, Kaui (this is the famous one where Jean-Louis Gassee attempted to sell Gil Amelio Be, Inc for multiple hundreds of $! I asked Ellen Hancock a question about Solaris support on PowerPC; not knowing she was a fan! My small place in Apple’s history)
August 1996 Apple Technology Symposium; keynote assistance, total technical manager, presentation of “How to Survive 300,000 hits a day” main hall
August to September 1996 Fairfax@Atlanta. Apple Computer Australia sponsored (through my time and donation of hardware- Power Macintosh 7600’s) the creation and management of this web site. It was designed by Brainwaave Interactive; I created the backend content management system using UserLand Frontier (before it was a web content management system) This system, which I termed Rosebud, automatically published static .html pages from a database engine; editors assigned images using a FileMaker front end. Rosebud managed the publishing of the dynamic information into the static site.
May 1996 Response to OptusVision Tender: before they went into the web realm. Wild and wooly presentation of the Apple AIX Network Server range!
May 1996 Attended PANPA Conference, Hobart
January 1996 San Francisco MacWorld
December 1995 January 1996 Consulting, Fairfax Publications, Golden Master

1997


November 1997 End of Year Update Roadshow (tecjhnology update for Apple’s customers in Australia)
June 1997 WWDC Update Roadshow (representing the technologies and strategies of Apple to customers and developers in Australia)
May 1997 WWDC, San Jose
February to April 1997 EasyRider ’97 Roadshow (Internet and Intranet using Apple and Apple-related technology)
January 1997 San Francisco MacWorld

1998


October 1998 Art of Illustration Roadshow: Adobe Systems: Australia and New Zealand
August 1998 Transition to Adobe Systems Pacific as Applications Specialist
June 1998 Re-presentation of Programming WebObjects I Course, Sydney
May 1998-June 1998 WWDC 1998 Update Roadshow, Publishing Update Roadshow
May 1998 Attended WWDC’98, San Jose, California
February 1998 Attended Programming WebObjects I and II course, Cupertino, California. WebObjects is a piece of technology Apple inherited (and still seems to be the forgotten middle child) when it purchased Steve Job’s NeXT, Inc in 1997. WebObjects 3.0 and later uses Java extensively as its programming language. I still miss WebObjects at Adobe …

1999


May 1999 Implementation of Adobe Solutions Network, Service Provider Program

May 1999

Future of Publishing Roadshow (Adobe InDesign, Adobe PressReady, Adobe GoLive, Adobe Acrobat)
February 1999 Adobe Tech Summit, San Jose

January 1999

Adobe Sales Conference, San Francisco

2000


October-November 2000 Stay on the Edge (Photoshop 6) Roadshow. Incorporating special 1.5 hour indepth session
November 2000 Shred the Web Roadshow: South East Asia (Singapore, Malaysia & India)
Appearred on CNBC “e” with Keith Lui. Live TV interview (not a prerecord)

August 2000

Adobe Tips, Tricks and Techniques Roadshow, Pacific
July 2000 Transition to Technical Resources Manager, Pacific and South East Asia for Adobe Systems

May 2000

Shred the Web Roadshow: Pacific

May 2000

Assistance to the 3DAP (PDF Guidelines for Magazine Advertising Delivery) in the creation of the “3DAP Guidelines for Digital Advertising Delivery”.
March 2000 Adobe Tips, Tricks and Techniques Roadshow: Pacific

1986-1989

September 89 As part of honeymoon, visited Apple Computer headquarters in Cupertino, California. Visited Apple Pacific and liaised with AppleCentre task force team and shopped at the “company store”.
April-September 1991 Moved from Technical Support Manager to Corporate Systems Engineer, responsible for Beneficial Finance, BHP Whyalla, Kinhill Engineers, Australian Submarine Corporation, F. H. Faulding & Co, and CRA Exploration. This role involved the all technical aspects of Macintosh usage in these corporates. Regular newsletters and fact sheets were also compiled and sent out, along with Corporate User Group Meetings and one-on-one technical sessions with their Technical Staff.

Early experimentation with Ethernet, QuickMail, Apple’s A/UX and other technically challenging products pioneered at AppleCentre Adelaide were introduced to these Corporates and in many cases adopted as Corporate platforms.

This role, whilst extending to September 1991, involved levels of Account Management and liaison with developers and distributors in Australia and the US. Close ties were created with Tri Data Communications, Keyway (now Conexus), Apple Sydney and Melbourne.

December 88 Completed writing chapter for the book “Tricks of the HyperTalk Masters” about using HyperCard as a front end tool to communications services. This book was published in 89 by the Waite Group, Mann County, USA. (ISBN 0-672-48431-5)
November 88 Employed and Trained new Technical Support team members. August 88 Appointed Manager of Technical Support at Random Access.
January 88 Appointed prime Technical Support contact for the Australian Submarine Corporation. This included daily liaison with Kay Lindley, PC & OA Supervisor and Brian Musker, MIS Manager.
September 87 Attended Apple Service Training in Sydney, achieving Level 1 Accreditation for Macintosh II hardware.
January 87 Moved from Sales to join the one man Technical Support team as a trainee Technical Support Analyst. In 1987 the world of Macintosh was just about to explode into ethernet networks, open systems with the Macintosh II and AppleShare. Supported Apple platforms ranged from the Macintosh, to the Apple II, to the rare Apple III.
August 86 Achieved highest sales in the month.
January 86 Commenced work at Random Access as a Junior Trainee Salesman. Job roles included store management and initial customer contact.

1990

June 1990 As Systems Engineer with AppleCentre Adelaide, provided prime Technical contact for the Co-operative Group bid. AppleCentre Adelaide won this bid over IBM Australia as “it was the safer choice”. This bid involved the integration of a network of Macintoshes into an IBM 4381 host.
April 1990 Attended “A/UX Systems Administration” course at Apple Computer, Sydney.
February 1990 Appointed AppleCentre “Building the Difference” Trainer/Motivator for AppleCentre Adelaide. Attended training course in Sydney in April.