Coldfusion CFDOCUMENT creates a red X

你。 提交于 2019-12-11 06:38:24

问题


I have an issue with a server to server call with ColdFusion.

Suppose I have two servers, each with a file:
www.Content.com/webpage.cfm
www.Badge.com/badge.jpg

My source code looks like this:

<cfdocument format="pdf" pagewidth="11" pageheight="8.5">

This is a simple PDF that was created to show issues with content generation on the server. This PDF uses an http:// reference to the badge server to show an image of a badged team member.

<BR />
<BR />

<img src="https://www.badge.com/badge.jpg" />

</cfdocument>

If I remove the CFDOCUMENT tags, the page renders perfectly and the JPG image shows exactly as it should. However, when I render the page as a PDF, the document does not include the JPG file and a large, ugly red X appears where the image otherwise should.

My web administrator has suggested that although the user may authenticate on badge and on content, the badge server might not authenticate to content or vice versa. How can I instruct coldfusion to take the user permissions from the currently logged in user and to pull the image?

I looked into using CFIMAGE and saving the image file into contents RAM, then writing the image to a variable before the PDF renders. That seems to generate a bug.

Thank you in advance for your feedback.


回答1:


Is the image always different? otherwise, you may want to save the image on your server locally, and use attribute localURL

http://www.ravenglass.com/blog/index.cfm/2010/6/9/Including-Images-in-a-PDF-created-in-CFDOCUMENT

Another possibility might be the SSL not being 'trusted' by CF. You can try fetching that image URL using CFHTTP and you will know if that's the case. see: Coldfusion: CFHTTP with SSL encrypted Page (https://) - got an error




回答2:


There's no need for CFHTTP to grab an image by URL and save it locally. Try this:

<cfscript>
myImg = imageRead("http://i.mycommentspace.com/23/2371.jpg") ;
imageWrite(myImg,"c:\myimage.jpg",0.8);
</cfscript>

BTW -- images in a CFDOCUMENT tend to work best when you use local paths, so once you've grabbed the image, try, for example <img src="c:/myimage.jpg" />




回答3:


localUrl="yes" (or =true) fails for https for which CF generating pdfs is painfully finicky.

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

You'll have to mind traversing up and down directories to get to your \images folder.



来源:https://stackoverflow.com/questions/10637542/coldfusion-cfdocument-creates-a-red-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!