I am totally stuck on this one. I am using an old Ben Forta tag cf_pdfform.
Im still using it because it makes writing to a PDF form and populating
fields easier than using the native cfpdf form population methods.
The problem is that any strings with UTF-8 characters get truncated at the
first character.
The method basically takes an XMl string of form data and the PDF form/file
and returns the populated PDF document (in this case in bytes). The XML I am
testing with looks good:
<?xml version="1.0" encoding="UTF-8"?> <xfdf><fields><field
name="activities"><value>Grave accent (à, è, ù): Over a or u, used primarily
to distinguish homophones: à ("to") vs. a ("has"), ou ("or") vs1. où
("where", note that ù exists1 only in this word). Over an e, 1indicates the
sound</value></field></fields></xfdf>
// PDF form input stream
formIS=CreateObject("java", "java.io.FileInputStream");
formIS.init(ARGUMENTS.PDFForm);
// Get PDF document object
PDFfactory=server.javaLoader.create("com.adobe.pdf.PDFFactory");
PDFdoc=PDFfactory.openDocument(formIS);
// Convert raw XML data to byte array
bytes=ARGUMENTS.XMLData.getBytes("UTF-8");
byteArrayIS=CreateObject("java", "java.io.ByteArrayInputStream");
byteArrayIS.init(bytes);
// Perform actual import
PDFdoc.importFormData(byteArrayIS);
//Call the PDFDocument object's save method
outputIS=PDFdoc.save();
// Read bytes
byteClass=CreateObject("java", "java.lang.Byte").TYPE;
PDFBytes=CreateObject("java",
"java.lang.reflect.Array").newInstance(byteClass, outputIS.available());
// And store them
outputIS.read(PDFBytes);
But when I executed the code below and then write the bytes via CFILE
CHARSET=UTF-8, the form field data is truncated in the resulting PDF.
Anybody have any ideas?
Brook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352781
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm