Archive for June, 2010

Writing formatted text to a Text Field in LC Designer XFA forms

Text fields in XFA forms have a limited support for XHTML markup, allowing rich text text fields in a fillable form.

You can populate these fields using JavaScript, but it requires a bit more trickery than a simple call to field.rawValue

Here’s a script that sets the value of a text field to contain styled text – so long as the text field has its property set to Rich Text

// This is the envelope that the HTML-formatted data needs to be placed in
// remember to escape quote marks

var envel = ‘<?xml version=”1.0″ encoding=”UTF-8″?><exData contentType=”text/html” xmlns=”http://www.xfa.org/schema/xfa-template/2.8/”><body xmlns=”http://www.w3.org/1999/xhtml” xmlns:xfa=”http://www.xfa.org/schema/xfa-data/1.0/” xfa:APIVersion=”Acroform:2.7.0.0″ xfa:spec=”2.1″><p style=”margin-top:0pt;margin-bottom:0pt;font-family:\’Myriad Pro\';font-size:10pt;text-decoration:none”>PLACEHOLDER</p></body></exData>';

// This is the HTML-formatted data
var jsdata = ‘<b>Hello</b> <i>Stylish</i> <u>World</u>’;

// put the HTML data in the envelope
jsdata = envel.replace(/PLACEHOLDER/g,jsdata);

// Load the XHTML into the field
// the …, 1, 1 arguments are required for exData to understand the content it seems

form1.sub1.TextField1.value.exData.loadXML(jsdata, 1, 1);

To extract the HTML afterwards, you will need to use “saveXML”. To get just the resulting plain text, you can access via rawValue as normal.

And as AnchorMan says: “Stay Stylish San Diego!” :-)

What’s this PDF ?

[This is not an official Adobe publication. This article may contain errors or omissions, and is subject to change without warning.]

While troubleshooting PDF-related problems, a number of tests come back again and again, and I intend with this article to give a brief overview of basic techniques and considerations on troubleshooting PDF problems.

Note that Reader is the free PDF reading software by Adobe. Acrobat has many more functions including PDF creation, manipulation, analysis, peer-reviewing, tracking, securing…. the list goes on.

Also note that sections referring to browser environments apply to Windows only, as browser plug-ins for Acrobat and Reader are not issued by Adobe for non-Windows operating systems (excpetion: on Mac OS X, browser integration exists only for Safari, but not other browsers)

1) Who’s Driving ?

When in a web browser in Windows, to check what plug-in is rendering the file, you can simply click somewhere in the PDF, and then use the key combo [Ctrl K]

If it is Reader or Acrobat, it will bring up a Reader or Acrobat dialog box.
If it is Acrobat, one of the sets of preferences will be “Convert to PDF”
If you’re in Reader, the PDF conversion preference set will be absent.

Otherwise, anything could happen – within the scope of the PDF reading application. If nothing happens, or a dialog for non-Adobe software appears, then you’re not displaying in Reader or Acrobat.

2) What Are My Rights ?

Through Acrobat, and some other Adobe software, it is possible to restrict how a user uses a PDF: whether they can print, save copies, modify, fill-in forms etc.

To determine this, right-click on a page in the PDF, and select “Document Properties” (available both in Acrobat and Reader)

The Security tab will show you what you are allowed to do with the PDF – whether you can print; add or remove pages, and a few more restrictions.

The Description tab will show you some useful information, of which the “PDF Producer”. Typical Adobe PDF producers are Acrobat, LiveCycle Designer, InDesign, PhotoShop, PDF Maker, PDF Library, Distiller and Adobe Central Output Server Print Agent 5.x.

If your PDF was not created with an Adobe product (in which case, it is not an “Adobe PDF”), and you are having PDF-related problems, then Adobe’s technical support may only be able to provide limited assistance (see http://kb2.adobe.com/cps/328/328140.html ). This also applies when you modify a PDF with a non-Adobe product; this will sometimes leave the PDF producer intact, depending on the software you use.

To test whether an issue occurs with a real Adobe PDF, and you have Acrobat (not Reader) installed, you can try printing the PDF to the “Adobe PDF” printer (available from the “Print…” dialog). This is commonly known as “re-frying” a PDF. This will create a static PDF, whose producer will then be “Adobe Distiller”. You can only do this if you have printing rights on the PDF. Use this new PDF to try to replicate the issue.

3) What Type of Form is my PDF ?

There are two main types of PDF forms that Adobe software produces: forms created directly in Acrobat (not Reader) through the menu item [Forms: Add or Edit Fields]; and those created in LiveCycle Designer (formerly “Adobe Designer”).

The first, created by Acrobat, are known as “AcroForms”. They have static (don’t move) form fields layered on top of static (non-changing) PDF pages.

The other, created by LiveCycle Designer, are called “Dynamic XFA Forms”, or “XFA’s”, whose structure are part encoded in XML, and partly in a native binary format. These have fields that are objects within the rendered PDF, as are nearly all other elements on the pages (with some exceptions, not discussed here). XFA forms can have items that repeat depending on the data entered, have areas of text that change depending on what data is in the form, etc, etc.

This is not to be confused with embedded Flash, which may also be used as a form, and constitutes neither an AcroForm or XFA Form. That would then be a PDF with “embedded content”. You can check this by right-clicking in the form: if you get the contextual menu for FlashPlayer, then you’re in an embedded content PDF.

In Reader, there is no sure-fire way of determining whether you have a dynamic XFA form. Even if the PDF Producer is LiveCycle Designer, you may have a static form that Designer produced.

4) Does My PDF Have a Problem ?

As far as software is concerned, there is only one thing that is certain: either data is badly formatted, or we hope it is well formatted.

There is a functionality in Acrobat (not Reader) that allows you to analyse a PDF, called “Preflight”, available through [menu Advanced: Preflight]

Preflight will analyse the current PDF for any defects, and if you choose, attempt to repair the issues.

A good rule of thumb is: if Preflight says there’s a problem, there’s definitely a problem. If Preflight reports no problems however, there’s no guarantee: it just means Preflight hasn’t been able to detect any problems. If you see a spider, there’s a spider. If you don’t see a spider, maybe there isn’t one – but maybe there’s one behind you.

So if Preflight reports issues with your PDF, and you have problems with that PDF, then it will be considered that the PDF is not compatible with Adobe software. Re-fry the PDF, and try again.

Installing Central on later OS’s

A frequent problem that occurs when installling Adobe Central Output Server is that sometimes a valid serial number is declined at install time. This most frequently happens when installing Central 5.5 on WIndows 2003.

Central 5.5 pre-dates the Windows 2003 operating system, which is not in the installer’s list of accepted OS’s.

To install correctly, you will need to copy the installer to a location on the local drive.

-Inside the installer directory, there is a setup.exe – right-click on this file and select the Compatibility tab

-Select Compatibility Mode for Windows 2000

-Repeat these steps also for the setup.exe in the Software\ directory

This will allow the correct recognition of Windows 20003

You do not need to repeat this for the installed binaries, these will accept the platform without any problems.