Does any one know why the image not display in pdf...
# cfml-general
v
Does any one know why the image not display in pdf for ColdFusion server 2021. I need the solution for this problem.
a
If you look at your question from the perspective of someone not sitting at your computer, looking at your code, and not having access to your brain... ... how much chance do you reckon they have at being able to answer that sensibly?
v
If somebody already worked for ColdFusion server 2021 in case of pdf images and resolve it then he definitely know the solution too.
c
it's not like there's only one way to generate a pdf and not like only one thing that could go wrong and no, there is not the one solution to it all.
👍 2
v
ok I am sending you code. You check and let me know where I am making mistake. Below is my code. It is working fine in local setup but when the same code used in hostek server it is not showing me image for ColdFusion server 2021.
<cfsavecontent variable="InvoiceData">
<img src="

https://cdn.pixabay.com/photo/2014/02/27/16/10/flowers-276014__340.jpg

" width="300" /> </cfsavecontent> <cfdocument format="PDF" pagetype="legal" marginbottom="0.4" margintop="0.4" marginleft="0.4" marginright="0.4" name="transcriptPdf" filename="#pdfPath#" overwrite="yes" fontembed="yes"> <cfdocumentsection> #InvoiceData# </cfdocumentsection> </cfdocument>
a
and no, there is not the one solution to it all.
This is precisely what I meant.
v
I understand but after sharing my code can you give me the solution of this problem?
a
The server would need to be able to call out to get the image. It might be blocked? Have you checked? Can you ssh onto the server and curl it to see if it's reachable from the server?
(that said... not 100% familiar with how
<cfdocument>
works? Does it embed images into the PDF, or just it just include links to them?)
m
Could be an SSL issue, or even a firewall issue. Code should work as you verified locally, so it must be something that’s different on the production server.
a
Although perhaps that's just an example. Are the images being used in the PDF on the CF server?
m
@Adam Cameron I think it actually embeds them.
a
OK so the server needs to be able to GET them then.
m
Yes
a
smoking gun.
m
@Vimlesh Parihar Have you tried a different image?
r
Status code 204 no content for me trying to view the image.
m
Smoking shell casing
@Rodney There might be something up with that CDN, I do see an image.
v
@mjhagen different images means like jpeg, jpg or other format Please clear your point.
I have tried using cfml function also like expandPath and baseUrl but with no success.
m
I’m terribly sorry for not being clear, I meant a completely different image either linked directly from the server, or hosted at another URL, as long as it’s not that same CDN.
v
I tried everything I could.
m
Everything? Well. I’m not sure what we can do then. Did you do the thing @Adam Cameron suggested?
r
Okay. I was able to view the image. As far as I can tell Cloudflare is forcing a download of the image and won't display it in the browser directly which is probably the problem.
🎉 2
a
This does not answer why "it works OK on [Vimlesh's] machine" though.
v
@Rodney so how can see the image in pdf without download.
r
Maybe a Cloudflare setting that allows viewing from your network? 🤷🏻‍♂️
v
Can you know which setting need to change in coldfusion server 2021.
to see the image
m
There’s no settings for that, sorry.
r
It's going to be a Cloudflare setting and not a ColdFusion setting most likely.
m
Yeah that ☝️
a
@Vimlesh Parihar have you done what I asked?
The server would need to be able to call out to get the image. It might be blocked? Have you checked? Can you ssh onto the server and curl it to see if it's reachable from the server?
v
How can I change or send request to change the setting
@Adam Cameron Let me try your Solution if it can help me out.
m
Vimlesh, you might just be running into a Cloudflare protection. I’m not sure there’s a simple way around that. If you need this specific image, you should just download it yourself, store it with your CF files and link to it that way.
v
Is it due to antivirus in my system?
a
If not ssh on to the server and curl it, then perhaps there's a CFML image function that will read from a URL?
m
You would use a local path then, using
<img src="file:///
v
ok
a
Looks like
imageRead
will take a URL. So write some code to try/catch an
imageRead
call to that URL, and dump out results / exceptions / etc and see if the CF server can reach the image. If not, then probs look into storing the images local to the CFML server as per Mingo.
👍 1
m
What’s the status @Vimlesh Parihar?
m
I would try using cfhttp to see what happens when you try to download the image... my gut is it is going to be a certificate issue. When I face connectivity issues it is normally one of these issues: • HTTPS Certificate not in the Certificate Store • Firewall blocking something on one of the sides • Destination Server actively blocking something • Moons Gravitational Pull causing bytes to be off.
🤔 1
🌝 1
a
Oh yeah,
<cfhttp>
is a better path than the
imageRead
one I suggested. More generic and will report more useful info
e
I would first just see if you can use a command line utility to download the image with cURL or lynx. Next, see the headers using Chrome or firefox to inspect the response headers given by the server(s) in question for the media object. see if you can just download the image using cfhttp or CfCurl
v
@mjhagen busy with some other task will check again once I will free.
👍 1
g
Try use the fille path as mentioned above Usually that works with pdf
agreed with others on the blocking part