2

I'm streaming images from outside the web root, using cfcontent. While the images are displayed correctly when the various pages are called directly in the browser, the images show a red X inside the generated pdf. On the export page:

<cfsavecontent variable = "gridCode">
    <cfinclude template="pathToGeneratedPage.cfm" >     
</cfsavecontent>
<cfdocument format="pdf" filename="#filename#" overwrite="yes" localUrl="yes">
    <cfdocumentsection >
        <cfoutput>#gridCode#</cfoutput>     
    </cfdocumentsection>
</cfdocument>

On the page with the content to be generated:

<img src="pathToDisplayPhoto.cfm?image=#someImage#" />

On the displayPhoto.cfm page:

<cfcontent type="image/*" file="#pathToUploadFolderOutsideWebRoot##url.image#" deleteFile = "No">

I included the cfdocument attribute localUrl="yes" because the default (no) was not working. Setting explicitly to "no" doesn't work either.

Any suggestions?

earachefl
  • 1,880
  • 7
  • 31
  • 55
  • Does this post help? http://stackoverflow.com/questions/4813587/dynamic-pdf-cfdocument-cfcontent-image-email-attachement – genericHCU Aug 15 '12 at 13:47
  • Travis, you know what, I saw that thread and for whatever reason didn't think it applied to my issue. But yeah, using instead of works. Thanks! Add it as an answer and I'll give you the points :) – earachefl Aug 15 '12 at 16:25

2 Answers2

2

I'm saving the created pdf and find localUrl="yes" (or =true) failed.

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

Worked for anyone scraping the bottom of the barrel for ideas. getCurrentTemplatePath() gets the filename as well as the path, so I had to remove it (hence the replace(...,"my.cfm"). I also tried expandPath(".") and that failed as well.

gordon
  • 1,152
  • 1
  • 12
  • 18
  • I was barrel scraping and this really helped! The regular way worked fine in ACF but not in Lucee. Referencing the local file system made it work. – steve Apr 30 '15 at 15:51
1

You have 'localUrl' set to yes, this means that Coldfusion will look at the file paths in the images and try and find them on the harddrive without making an HTTP or HTTPS call, so Its trying to open 'pathToDisplayPhoto.cfm?image=#someImage#' as an Image, but because its not an HTTP request it won't proccess the CFML.

If you set loclUrl to No that should fix the issue.

cfdocument ref - look for localUrl in the params list.

Dpolehonski
  • 948
  • 6
  • 11
  • Thanks... but adding localUrl="yes" was something that I tried because using the default (no) didn't work. Setting explicitly to "no" doesn't make a difference. – earachefl Aug 15 '12 at 14:44