Skip to main content
Participating Frequently
November 10, 2010
Question

Unicode (international) characters in cfpdfform with LiveCycle PDFs

  • November 10, 2010
  • 1 reply
  • 2400 views

Hi all

These are the details of my environment:


ColdFusion version: 8.0.1
Update level: C:/ColdFusion8/lib/updates/chf8010004.jar
Server OS: Windows Vista 64
Web server: Apache

I'm using cfpdfform in ColdFusion 8 to read a Livecycle 8.2.1 pdf form straight into the browser window, enter text into a couple of fields and then submit the form back to the same CF page and use the submitted XML to populate the same form.

So, the relevant bit of my code is as follows:

<cfif IsDefined("PDF")>
    <cfpdfform action="read" source="#PDF.content#" xmldata="myXMLData" />
    <cfset myXMLData = XMLParse(myXMLData)>
    <cfpdfform action="populate" source="c:\temp\myPDFForm.pdf" xmldata="#myXMLData#" overwritedata="true" />
<cfelse>
    <cfpdfform action="populate" source="c:\temp\myPDFForm.pdf">
        <cfpdfsubform name="topmostSubform">
            <cfpdfformparam name="TextField1" value="Hello! The time is #TimeFormat(Now(), 'HH:mm:ss')#" />
        </cfpdfsubform>
    </cfpdfform>       
</cfif>

This all works just fine, except that any multibyte unicode characters (e.g. Chinese) I enter into any text fields are lost (turned to question marks) when the form is populated from the submitted XML, even though I can see that the Unicode characters remain intact if I do a cfdump of the myXMLData variable on page submission.

I ordinarily have no problems with Unicode. I can write unicode characters in multiple foreign character sets to database and retrieve them just fine. I have site pages in several international character sets, and, as I have stated, the text I enter is displayed correctly in the correct foreign characters when I view a cfdump of the submitted form, so this appears to be specifically related to the PDF form populate side of things (or a setting in LiveCycle).

I have an inkling that the cause is that the LiveCycle form has its  text fields set to allow rich text and has a specific font set against  the fields, so I'm wondering whether the foreign character font, which  displays fine when I enter it into the form, is being lost (overwritten by the LiveCycle field font) when read  back into the form. Any ideas as to how to overcome this problem would  be gratefully accepted.

This topic has been closed for replies.

1 reply

Inspiring
November 10, 2010

On 11/11/2010 12:01 AM, jtchivers said:

Chinese) I enter into any text fields are lost (turned to question marks)

question marks (?) indicate a serious encoding error (like garbaged data). not

really a LC expert but i can offer a few hints:

- didn't see any cfprocessingdirective, tried that?

- can you writeout the unicode data to PDF ok using cfdocument?

- reading in the new unicode data from an XML file & maybe forgetting the

"charset" option?

I have an inkling that the cause is that the LiveCycle form has its text

fields set to allow rich text and has a specific font set against the

fields, so I'm wondering whether the foreign character font, which displays

fine when I enter it into the form, is being lost (overwritten by the

LiveCycle field font) when read back into the form. Any ideas as to how to

overcome this problem would be gratefully accepted.

i want to say not likely, as simple font/rendering errors are usually shown as

empty squares.

jtchiversAuthor
Participating Frequently
November 11, 2010

Hi Paul

Thanks for your suggestions.

I tried cfprocessingdirective, but it made no difference, and since the Chinese characters were displayed correctly in the cfdump, I thought it wouldn't be that (but I wasn't sure).

I dumped the submitted PDF form XML to cfdocument and all the Chinese characters were there and displayed correctly.

<cfdocument format="PDF">
     <cfdump var="#myXMLData#" />
</cfdocument>

- reading in the new unicode data from an XML file & maybe forgetting the

"charset" option?

I'm reading the XML in directly through the cfpdfform tag, so there is no charset option. Since the Chinese characters are displayed correctly on page or to a cfdocument, I don't believe the problem is on the read, but on the populate action.

Out of interest, I tried copying the Chinese characters directly into the PDF form field on LiveCycle and saving the form. When the form was displayed in the browser (using cfpdfform and action populate), the Chinese characters were intact.

This all points strongly towards the issue being the populate action on the cfpdfform tag, but there appears to be very little I can do about it (ColdFusion's power is that I can read a PDF form and write to one using the cfpdfform tag, but it does mean that there is limited scope for errors, which is good on the one hand and bad on the other - if it's a bug, I'm a bit stuck).

It's not really a LiveCycle issue from what I can see, as LiveCycle is retaining the Chinese characters in a form when they're already present.

Thanks for your help and suggestions anyway, Paul.

Inspiring
November 11, 2010

let me see if i can get the attention of somebody who knows more about cfpdfForm

than i do. its for sure an encoding error, just need to see where we can affect it.