Image not showing in cfdocument pdf for coldfusion 10

I am using ColdFusion 10 Enterprise Edition and cannot display images when using CFDOCUMENT to create a PDF file. The following is a snippet of the code I'm using:

 <cfsavecontent variable="report"> <table align='center'> <cfoutput query="VARIABLES.result"> <tr> <td> <div class='addInfoDetails'>#SHOWINFO#</div> </td> </tr> </cfoutput> </table> </cfsavecontent> 

In the above code, the VARIABLES.result query comes from the database, and SHOWINFO is a variable containing the image and text. For instance:

  SHOWINFO = "<p> Hi This is the test information <img alt="image" src="../TestBank/test/info/5KQ.jpg"/> </p>" 

Here, if you reset the SHOWINFO variable inside CFSAVECONTENT , the image is displayed correctly. But when I convert it to PDF using CFDOCUMENT, the image is not displayed.

Below is the code that I use to create pdf:

 <cfdocument format="PDF" saveasname="TestPDF"> <cfoutput>#report#</cfoutput> </cfdocument> 

Thanks in advance.

+4
source share
2 answers

I fixed it by adding the attribute "localUrl = yes" to the CFDOCUMENT tag.

Now it works great for me.

+4
source

I save the created pdf file and find localUrl="yes" (or =true ). It turns out that CF-generating PDF files for https addresses is very painful.

 <img src="file:\\\#replace(getCurrentTemplatePath(),"my.cfm")#images\my.png"> 

Worked for me if someone scraped the bottom of the barrel for ideas. getCurrentTemplatePath () gets the file name as well as the path, so I had to delete it (therefore, replace (..., "my.cfm"). I also tried expandPath ("."), and that also failed.

Didn't try Dave Anderson's intriguing offer to capture Coldfusion image CFDOCUMENT creates red X

+1
source

Source: https://habr.com/ru/post/1495469/


All Articles