SVG in cfdocument? <img> problems

Is it possible to print SVG graphics with cfdocument?

I generally have a lot of problems with images.

Inline images such as the following work:

Images from the server with src=“file:///” also work if attribute localUrl=true

Images with src="http:// or https://… are never printed. Even if they can display in a browser on the webserver.

What am I doing wrong? It worked on my old Coldfusion server…

Thanks,
Allan

Here is the related ticket.
https://luceeserver.atlassian.net/browse/LDEV-419

workaround, generate images from the svg

1 Like

Thank you, but I don’t understand how this 6-year-old ticket is supposed to help me.

Thanks, I can also generate PNG directly. But the PDF is about 10 times smaller with SVG, so I would prefer that. Unfortunately, it doesn’t work with PNG either.

The following code:

<cfdocument format="pdf">
	<h1>Welcome to Lucee</h1>
	<h5>Example Page</h5>
	<p>Example for <b>Cfdocument</b></p>
	1<img src="https://dev.moby.ch/img/map.png" width="1191" height="624" alt="">2
</cfdocument>

result:

And it doesn’t matter whether it’s PNG, JPG, http, or https—no images are displayed in the PDF.

Any ideas what could be causing this?

Thanks,
Allan

Hi all

The image problem seems to be an issue with nslookup. When I move the images to production and adjust the URLs accordingly, they are also printed in the PDF. Now I’m wondering what I need to do to make it work in the dev environment as well. The images are displayed in the browser…

I also found out that SVGs are printed in Classic mode.

Does anyone use a different PDF engine that offers a little more functionality? Perhaps with examples or code to share?

Thanks,
Allan

Show us some of your code?

Lucee has a lot of tests, they are a good starting point. Some are under the main repo, extension specific tests are in the extension repo

That said, these tests are mostly headless, i.e. without a webserver, which means these images url issues aren’t covered.

I have been slowly adding additional tests using a webserver for this over on Lucee testlab and specific repos

The Code is one comment above…

Can your dev server running Lucee access the images? Do a cfhttp request to an image to check.

1 Like

@martin you made my day! It’s not the DNS, it’s the certificate. However, I still don’t know how to fix that. At least I noticed when testing with cfhttp that I’m still redirecting everything from http to https, which why http never worked. I could have thought of that earlier. Thanks!

I would also be very grateful for any tips on how to fix the certificate issue.

@Schumatech It will depend on what the issue with the certificate is. However, problems are often solved by making sure you are using an up-to-date version of Java. You can also try importing the certificate:

It looks like that will only work with Lucee 5 though.

There is also a section in the admin to install certificates:
Services > SSL Certificates

You may have some luck with these options.