Cannot write special characters in PDF

Hi,

When I try to create a PDF with cfdocument and write characters like č,ć,đ Lucee just ignores it. So instead of something like “čitluk” i get “itluk”. All my charsets inside the Lucee admin are set to utf-8 and Lucee has no problem writing these characters into a .txt file.

I have tried using cfprocessingdirective for utf-8 encoding but it doesn’t work. I don’t know if this info helps, but when I download my PDF and open it with Adobe Acrobat I can see under font properties that the encoding is Ansi.

Does anybody know what could be causing my issue and how to fix it?

P.s. Is there a way to list all Lucee embedded fonts?

Thanks!

OS: AlmaLinux 8.4
Java Version: 15.0.2
Tomcat Version: Apache Tomcat/9.0.31
Lucee Version: 5.3.8.206

<cfdocument format="pdf" fontembed="true" fontnames="MyCustomFont">
  <p style="font-family:MyCustomFont">Willble wobble whops wilmer</p>
</cfdocument>

And then in the URL, you set something like

<cfset myfont1 ="http://localhost/myfont/MyCustomFont.ttf">

or you could place the fonts globally available to lucee tomcat

mkdir /opt/lucee/lib/fonts
cp yourFont to /opt/lucee/lib/fonts
chown -R /opt/lucee/lib/fonts nameofServiceUserforLucee.nameofServiceUserforLucee
systemctl restart lucee_ctrl

You can add fonts directory with:

this.pdf.fontDirectory = "/assets/main/fonts";

Hey Terry thank you for the reply, but I have already successfully imported a custom font globally with a latin extended charset before and still had the same problem. I also get an error “is not allowed for tag” when I try to use the fontnames attribute of the cfdocument tag. I also don’t see it in the documentation.

Did you restart Lucee? after you imported the fonts and can you post the code in on trycf or here so we all can attempt to correct the issue.

I created a fonts.jar file in opt/lucee/lib and then restarted Lucee. I noticed after that Lucee created a fonts folder in the WEB-INF/lucee/ folder and my .ttf file was located there. After that I created a PDF and could use the new font, but I still cannot write characters like “Č”.

It maybe a system os (the user your lucee tomcat is running at) doesn’t understand or have that font you need. Have you tried the ascii CHR attribute? #CHR(&##268;)# and making sure its loaded in the os? it should be in /usr/share/fonts/

I cannot write the character Č in a PDF in any font, I already tried outputing it with CHR(268) and it didn’t work.

Its not CHR(268) its CHR( POUND-SIGN(“#”) 268 SEMI-COLON (“;”)

You have to add the FONT to the OS and reboot.
java user for your lucee instance needs to understand font, as that is the underlying worker process that is generating the PDF, not the browser which understands UTF. Additionally, turn off SELINUX temporarily, “setenforce 0” if it is not already off, restart your services and try again after the font is loaded in the OS. Also could try the HTML unicode according to one of my cowokers, as an HTML object "&#269;" č