curious one this.
I'm working on a process that generates PDF files, combining data from various sources. The last piece of this process I need to complete is merging in image files.
This is actually fairly straightforward but the problem I have is the image files aren't stored with file extensions. Locally, I can change the filename, but in production this isn't an option.
So because a filename looks like : B71637CB-A49C-0653-EF813918736BDEB7
This will not work:
<cfimage action="writeTobrowser" source="#FilePath#>
Same with
<img src="#FilePath#">.
So, any ideas on how I can work around this? Here's the code in context:
<cfdocument format="PDF" name="report" filename="#fileToDownloadimage#" overwrite="yes">
<cfdocumentsection>
<cfimage action="writeTobrowser" source="#FilePath#.jpg">
</cfdocumentsection>
</cfdocument>
If you need to embed the images into the PDF document, try HTML's inline image capabilities:
<cfset fileLocation = "/path/to/images/B71637CB-A49C-0653-EF813918736BDEB7">
<cfset imageContent = fileReadBinary(fileLocation)>
<cfset imageContentAsBase64 = toBase64(imageContent)>
<cfoutput>
<img src="data:image/jpeg;base64, #imageContentAsBase64#" />
</cfoutput>