ColdFusion CFPDFFORM does not populate PDF form fields

I created a quick PDF file with two form fields, first and last name (or FirstName and LastName) using the "Submit" button and used the following code to try to fill in these fields in a new PDF file:

<cfpdfform action="populate" source="#variables.AbsPath#\test.pdf"> <cfpdfformparam name="FirstName" value="foo" /> <cfpdfformparam name="LastName" value="bar" /> </cfpdfform> 

However, I get this error:

 The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values. Platform, Locale, and Platform Name must not be null 

I tried reading the PDF file to make sure the form fields are correct and they are:

 <cfpdfform action="read" source="#variables.AbsPath#\test.pdf" result="fields" /> <cfdump var="#fields#"> 

The structure is unloaded:

 FirstName: [empty string] LastName: [empty string] Submit: [empty string] 

I tried searching for Adobe documents and other sites, but cannot find a solution to this error. I also tried adding the "destination" parameter to the cfpdfform tag if necessary, but got the same result. PDF file exists. Any ideas? Thanks in advance.

UPDATED: Here is the stack trace:

 java.lang.NullPointerException: Platform, Locale, and Platform Name must not be null at com.adobe.fontengine.fontmanagement.platform.PlatformFontDescription.<init>(Unknown Source) at com.adobe.fontengine.font.opentype.OpenTypeFont.getPlatformFontDescription(Unknown Source) at com.adobe.fontengine.font.FontImpl.getPlatformFontDescription(Unknown Source) at com.adobe.fontengine.font.FontImpl.getPlatformFontDescription(Unknown Source) at com.adobe.fontengine.fontmanagement.platform.PlatformFontResolverImpl.addFont(Unknown Source) at com.adobe.internal.pdftoolkit.core.fontset.impl.PDFFontSetImpl.addFont(Unknown Source) at com.adobe.internal.pdfm.util.FontSetBuilder.loadFontsPath(FontSetBuilder.java:418) at com.adobe.internal.pdfm.util.FontSetBuilder.loadSystemFonts(FontSetBuilder.java:346) at com.adobe.internal.pdfm.util.FontSetBuilder.makePDFFontSet(FontSetBuilder.java:239) at com.adobe.internal.pdfm.util.FontSetBuilder.getPdfFontSet(FontSetBuilder.java:93) at com.adobe.internal.pdfm.PDFM7Factory.getPdfFontSet(PDFM7Factory.java:97) at coldfusion.document.DocumentServiceImpl.getAssemblerFontSet(DocumentServiceImpl.java:512) at coldfusion.pdf.PDFForm.populateFields(PDFForm.java:292) at coldfusion.tagext.lang.PDFFormTag.doEndTag(PDFFormTag.java:347) at cfsubmit2ecfm1224790315.runPage(C:\ColdFusion\wwwroot\nVision\projects\test\pdfform\submit.cfm:9) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:381) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:94) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126) at coldfusion.CfmServlet.service(CfmServlet.java:200) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) 
+2
source share
4 answers

I believe this is a font problem on a specific server. This is why the same code will work on the production server, and not on the testing server. I am experiencing the same problem, and although I do not have a great solution, what I found out.

  • The stack stack shows that there is an error getting getPlatformFontDescription of the OpenType font.
  • Our Windows server lists TrueType fonts as OpenType . Your?
  • Using the following code fixed the problem, but this only works.

     <cfpdf name="local.pdffile" action="read" source="some path" > <cfscript> 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.Acroform.setField("Field1",Arguments.Value1); local.Acroform.setField("Field2",Arguments.Value2); // etc. local.pdfStamper.setFormFlattening(true); //optional local.pdfStamper.close(); local.pdfReader.close(); local.pdffile = local.outputStream.toByteArray(); </cfscript> <!--- 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" /> 
  • Additional diagnostics: A simple listing of all the fonts available on the server using the Java subsystem also fails. Try it.

      <cfset list=createobject("java","com.adobe.internal.pdfm.util.FontSetBuilder")> <cfdump var="#list#"> <cfset dummy = list.getPdfFontSet()> <cfdump var="#dummy.toString()#"> <!--- this should fail ---> 
  • Currently, we have "fixed" our problem by deleting all fonts from the Windows \ Fonts folder and selecting damaged ones. This is painstaking but seems to work.

Good luck

+6
source

I just wrote a script to fix this problem here: fooobar.com/questions/1478291 / ...

This is a problem with a font file that does not have a locale or platform name. PDF features in Coldfusion call it

 <cfset list=createobject("java","com.adobe.internal.pdfm.util.FontSetBuilder")> <cfset dummy = list.getPdfFontSet()> 

This lists each font, and if it is bad, it throws an exception and kills your process.

My code lists all the fonts in c: \ windows \ fonts and then reports bad ones.

Here are the ones we have problems with:

 AdobeNaskh-Medium.otf Mechanical.TTF msgothic.ttf MyriadArabic-Bold.otf MyriadArabic-BoldIt.otf MyriadArabic-It.otf MyriadArabic-Regular.otf 
+2
source

You did not indicate how you created your PDF file. Depending on how you created the PDF file, the form fields may be contained in a subform. PDF files created from templates in LiveCycle will do this. By default, LiveCycle will name the subform "form1". To fill out these form fields, you need to include the cfpdfsubform tag. See the documentation here: cfpdfsubform documentation

So your code will look something like this:

 <cfpdfform action="populate" source="#variables.AbsPath#\test.pdf"> <cfpdfsubform name="form1"> <cfpdfformparam name="FirstName" value="foo" /> <cfpdfformparam name="LastName" value="bar" /> </cfpdfsubform> </cfpdfform> 

The code you included to read your PDF should show you whether the fields are included in the subform. The dump will display the form fields contained in another structure. This will be the name that you use in the cfpdfsubform tag name attribute.

NTN.

+1
source

I only realized, after reading your question, that I was going the wrong way. I thought you had a problem filling the fields in pdf. But your real problem is the null pointer. Doh! Sorry for the confusion.

Usually this error tells you that the variable you are using is not defined. The only variable that I see in your example is # variables.AbsPath #. You specify the scope of the variables. It's right? The variable area is available only on the page on which it was created (and included in the pages).

You did not specify how you define this variable. Can you share this?

Is the error random or all the time?

Are you sure that the error occurs on this line of cfpdfform, and not somewhere else? I would put a cftry / cfcatch block around your code and reset the cfcatch structure to get a more specific error. Can you try this and send back?

0
source

All Articles