I'm trying to read in a pdf form, complete the fields and send it to the user's browser. However I approach it, whenever I use a cfpdf type of tag, I get the error message "Platform, Locale, and Platform Name must not be null".
For example the following flags an error on the cfpdfformparam line:
<cfpdfform action="populate" source="Order Acknowledgement Form4.pdf">
<cfpdfformparam name="Text1" value="Test Data">
What am I doing wrong?
Using CF9.01 Developer edition. The PDF was created in Acrobat X from a Word file.
The following works and lists the form field, so I'm guessing that it's not a problem with the source file.
<cfpdfform source="Order Acknowledgement Form4.pdf" result="resultStruct" action="read"/>
I believe this is a font issue with the specific server being used. This is why the same code will work on the production server and not the testing server. I am experiencing the same issue and although I don't have a great solution here's what I learned.
1. The stacktrace shows that there's an error getting the getPlatformFontDescription of an OpenType font.
2. Our Windows server is listing some TrueType fonts as OpenType. Is yours?
3. Using the following code corrected the issue:
<cfpdf name="local.pdffile" action="read" source="some path" >
local.pdfReader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(tobinary(local.pdffile));
local.outputStream = createObject("java", "java.io.ByteArrayOutputStream").init();
local.pdfStamper = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(local.pdfReader,local.outputStream);
local.Acroform = local.pdfStamper.getAcroFields();
//Populating Form Fields
local.pdffile = local.outputStream.toByteArray();
<!--- flatten="no" must be set or you will get the error again --->
<cfpdf action="write" source="local.pdffile" destination="#variables.OutputPath##local.UUID#.pdf" overwrite="yes" flatten="no" />
4. Simply listing all the fonts available to the server using the Java subsystem also fails. Try this.
<cfset dummy = list.getPdfFontSet()>
<!--- this should fail --->
5. We have "fixed" our problem at the moment by removing all the fonts in the Windows\Font folder, fixing or isolating any corrupt fonts, and reinstalling them. It's painstaking but seems to work.
Hi, had the same issue myself.
My solution (which compliments the above correct answer):
Here's the list of fonts that Adobe installs with the Creative Suite 6:
1. Copy all these fonts to the separate folder and remove from the Windows/Fonts directory.
2. Test CFPDFFORM bit and confirm it's working
3. Manually add them back.
In my case it turned out none of those fonts were corrupt per se, though probably weren't installed the way Windows like it. Re-installing it manually somewhat fixed the issue.
One more note: I've removed all until MyriadPro (including it) constantly refreshing the page containing CFPDFFORM bit until it worked. So for those trying to get a fast fix, I'd recommend starting with MyriadPro family. It just may turn out it's the one that breaks the things.
Hope this helps someone out!
I've created a cfm page that enumerates all the fonts in the c:\windows\fonts directory and lists the ones that are incompatible with the CF PDF components:
<cfset fontobj = createobject("java","com.adobe.fontengine.fontmanagement.FontLoader") >
<cfdirectory action="list" directory="c:\windows\fonts" name="fontdir">
<table border="1" style="border-collapse:collapse">
<cfset loaded = fontobj.load(createobject("java","java.net.URL").init("file:///C|/win dows/fonts/#fontdir.name#"))>
<cfif arraylen(loaded) gt 0>
<cfset dummy="#loaded.getPlatformFontDescription().toString()#" >