Skip to main content
Participating Frequently
October 4, 2024
Question

Cfpdfform populate not working

  • October 4, 2024
  • 3 replies
  • 7125 views

We have using the cfpdfform to populate the xmldata on the pdf, suddenly it stopped working. when we try to read the same pdf using the cfpdfform function it displays the content in struct. but when we open the pdf it shows blank. We are using coldfusion 2023 patch update upto 8. we haven't made any code changes recently, but it stop working suddenly after 30th Sept.

    This topic has been closed for replies.

    3 replies

    Charlie Arehart
    Community Expert
    October 4, 2024

    It seems you think "coldfusion is broken", and whether on update 8 or 10. Is that right? Since we three (Dave, BKBK, and I) have not heard of this issue before (and we're helping people here every day), that really puts the onus on you to demonstrate that the issue is not on your end.

     

    Bkbk asked below for you code. I'd go further and ask you to please offer simple stand-alone demo code (perhaps even just a single line of code) along with a pdf that reflects your concern.

     

    That would have two benefits. First, it would allow any of us to confirm your concern. Second, it might even help you to see that the problem is on your end.

     

    In other words, if such simple demo code and pdf would work for you, then it would help you see that the issue is NOT with CF itself but instead with your FAILING pdf or code. You could study the differences. On the other hand, if such demo code did NOT work for you but DID work for us, then that would show that there was some environmental issue on your end.

     

    I'm not saying whether there IS an issue on your end, nor am I saying there ISN'T an issue with CF. But I'm saying you can help prove things either way, by creating a simple standalone demo you can share with us. 

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Community Expert
    October 4, 2024

    I hope Dave's suggestion solves the problem.

    If it doesn't, then please share your code so we can better understand the issue.

    BKBK
    Community Expert
    October 9, 2024

    Thanks for sharing the code, @sathiyanarayanan_7692 . I have been experimenting with your code, using a form that I created myself (attached), in combination with various XFA versions of your XML file.

    (Mind you, the referenced page contains an error. The final closing tag of the last XML should be "</xfa:data>", not "</xfa>" . I have reported the error to Adobe.) Thought I'd share my experiences after going at it for some hours.

     

    My test code, together with the latest version of the XML, follows :

    <!--- Specify the XML file to populate a PDF form. ---> 
    <cfset formdata='<?xml version="1.0" encoding="UTF-8"?>
    <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">  
    	<xfa:data> 
    		<form1>        
    	        <ordDate>10/02/2024</ordDate>
    	        <ordReqFillDate>11/02/2024</ordReqFillDate>
    	        <ordCost_Ctr>999999</ordCost_Ctr>
    	        <FlrUnit>Acute 9 East</FlrUnit>
    	        <ordFilledBy></ordFilledBy>
    	        <ordCheckedBy></ordCheckedBy>
    	        <Misc1>Cocoa mix, 50 pkt per box</Misc1>
    	        <MiscAmt1>10</MiscAmt1>
    	        <Misc2>Coffee Creamer 12 oz</Misc2>
    	        <MiscAmt2>20</MiscAmt2>
    	        <ordby>Manimaran, Sathiyanarayanan</ordby>
            </form1>
        </xfa:data>	
    </xfa:datasets>'/>
    	
    <cfset xmlFormData=xmlParse(formdata)> 
    
    <!---<cfdump var="#xmlFormData#" abort="true">--->
    
    <!--- Polpulate PDF form with XML data --->
    <cfpdfform source="#expandpath('prefilledform.pdf')#" 
    destination="#expandpath('filledform.pdf')#" action="populate" XMLdata="#xmlparse(formdata)#" overwrite="yes"/>
    
    <!---
    <cfpdfform  action="read"  source="#expandpath('filledform.pdf')#" result="test" />
        <cfdump var = "#test#" />
     --->

    Result:

    The file filledForm.pdf is created, but its fields are all empty.

    All the form fields in <cfdump var = "#test#" /> are also empty.

     

    Nevertheless, I can suggest a workaround (that works!):

    <!--- Specify the XML file to populate the PDF form. ---> 
    <cfset formdata='<?xml version="1.0" encoding="UTF-8"?>
    	<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
    	    <xfa:data>
    	        <F>          
    	            <P1>            
    	                <ordDate>10/02/2024</ordDate>
    	                <ordReqFillDate>11/02/2024</ordReqFillDate>
    	                <ordCost_Ctr>999999</ordCost_Ctr>
    	                <FlrUnit>Acute 9 East</FlrUnit>
    	                <ordFilledBy/>
    	                <ordCheckedBy/>
    	                <Misc1>Cocoa mix, 50 pkt per box</Misc1>
    	                <MiscAmt1>10</MiscAmt1>
    	                <Misc2>Coffee Creamer 12 oz</Misc2>
    	                <MiscAmt2>20</MiscAmt2>
    	                <ordby>Manimaran, Sathiyanarayanan</ordby>
    	            </P1>
    	        </F>
    	    </xfa:data>
    	</xfa:datasets>'/>
    	
    <cfset xmlFormData=xmlParse(formdata)> 
    
     <!--- Access the elements inside the XML and get their values. If element not found, set the value to empty string.  --->
    <cfset ordDate = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordDate.xmlText ?: "">
    <cfset ordReqFillDate = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordReqFillDate.xmlText ?: "">
    <cfset ordCost_Ctr = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordCost_Ctr.xmlText ?: "">
    <cfset FlrUnit = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.FlrUnit.xmlText ?: "">
    <cfset ordFilledBy = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordFilledBy.xmlText ?: "">
    <cfset ordCheckedBy = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordCheckedBy.xmlText ?: "">
    <cfset Misc1 = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.Misc1.xmlText ?: "">
    <cfset MiscAmt1 = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.MiscAmt1.xmlText ?: "">
    <cfset Misc2 = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.Misc2.xmlText ?: "">
    <cfset MiscAmt2 = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.MiscAmt2.xmlText ?: "">
    <cfset ordby = xmlFormData["xfa:datasets"]["xfa:data"].F.P1.ordby.xmlText ?: "">  
       
     <cfpdfform action="populate" source="#expandpath('prefilledform.pdf')#" destination="#expandpath('filledform.pdf')#" overwrite="yes">
    <cfpdfformparam name="ordDate" value="#ordDate#">
    <cfpdfformparam name="ordReqFillDate" value="#ordReqFillDate#">
    <cfpdfformparam name="ordCost_Ctr" value="#ordCost_Ctr#">
    <cfpdfformparam name="FlrUnit" value="#FlrUnit#">
    <cfpdfformparam name="ordFilledBy" value="#ordFilledBy#">
    <cfpdfformparam name="ordCheckedBy" value="#ordCheckedBy#">
    <cfpdfformparam name="Misc1" value="#Misc1#">
    <cfpdfformparam name="MiscAmt1" value="#MiscAmt1#">
    <cfpdfformparam name="Misc2" value="#Misc2#">
    <cfpdfformparam name="MiscAmt2" value="#MiscAmt2#">
    <cfpdfformparam name="ordby" value="#ordby#">
    </cfpdfform>

     

    BKBK
    Community Expert
    October 9, 2024

    To add to my last post, I am on ColdFusion 2023, Update 10 (on Windows 10 Pro)

    Community Expert
    October 4, 2024

    Did you stop and restart CF immediately prior to that? Do you see anything in the error logs after that? Is this happening in multiple environments, or just this server? If you have multiple environments, can you update CF to update 10 on one of them and retry?

     

    Dave Watts, Eidolon LLC
    Participating Frequently
    October 4, 2024

    i have tried restarting coldfusion server, it is not working. initially, i tried in cf patch update 10, after i thought it might be patch update and unistall that still it shows blank pdf. we have 3 environment 2 prod and one dev. all 3 environment showing blank pdf. two prod using cf 2023 patch update 8. in dev we tried cf 2023 patch update 10, even uninstall patch update upto 6 and tried in dev still showing blank pdf.

     

     

    Community Expert
    October 4, 2024

    Did you check the error logs?

     

    Dave Watts, Eidolon LLC