Pergunta

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.

Foi útil?

Solução

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

Outras dicas

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" />

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top