salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.52k stars 2.09k forks source link

Fonts not correct in PDF Download/Creation #9056

Open ipbroad opened 3 years ago

ipbroad commented 3 years ago

Hi all, not sure what I am doing wrong. I’ve changed the font in a pdf template to what I want but when I come to print/download/email the PDF it has not changed. All the HTML is correct to what I want and on screen in the editor it has changed but when I come to print it has not. For the life of me I cannot figure what I am doing wrong. Many thanks for any help.

johnM2401 commented 3 years ago

If you could fill in as much of the template as possible when raising an issue, (Such as SuiteCRM Version/PHP Version/Steps to replicate), that would be very much appreciated and would help any developers investigating the issue.

Also, if you could provide some examples of Fonts used, that would also be appreciated

Thanks for raising!    

Relevant Forum Thread: https://community.suitecrm.com/t/fonts-in-pdf-not-working/78716/

tsmgeek commented 3 years ago

Built in mPDF 5.x supports specific fonts by default

https://mpdf.github.io/fonts-languages/fonts-in-mpdf-5-x.html https://github.com/salesagility/SuiteCRM/blob/master/modules/AOS_PDF_Templates/PDF_Lib/config_fonts.php https://github.com/salesagility/SuiteCRM/tree/master/modules/AOS_PDF_Templates/PDF_Lib/ttfonts

I found that I had to slipstream in and override the config_fonts.php file and add in my custom fonts.

mPDF 7.x is easier but SuiteCRM has not yet upgraded to add hooks directly for fonts, its harder unless they upgrade to later mPDF.

afaik

ipbroad commented 3 years ago

thanks tsmgeek I tried the above and no luck - everything is the latest version but no matter what I try this just doesn't work.

maadc commented 3 years ago

cherub-chum explained the issue in the Forum Thread .

TinyMC and your browser are using different fonts then the module which prints the pdf's. Thus you have to add the fonts manually in mPDF.

  1. Open _SuiteCRM/modules/AOS_PDF_Templates/PDF_Lib/configfonts.php
  2. There you will find the array fontdata. It was at line 94 in my file.
  3. You have to add your fonts there, just like the already added ones. In the comment above the array is a little instruction.
  4. Upload you fonts to the font-folder: /_public_html/SuiteCRM/modules/AOS_PDF_Templates/PDFLib/ttfonts

There you go. Problem solved.