-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2126 - Allow setting dompdf options, e.g. an external font folder #21423
Conversation
(Standard links)
|
@demeritcowboy are you planning on putting the metadata in as well for the setting? I like this idea myself I haven't r-run this as yet tho |
3ce4340
to
cefc297
Compare
Good idea. I wasn't sure what settings to give it - I've made it like other multi-select arrays, just there's no list of options. |
@demeritcowboy I think I would go with just a setting for the specific option you want to override rather than an open ended array - we have had problems with the open ended arrays before & I think you really just want to override one key within it? |
Thanks @demeritcowboy and sorry It seems I missed your comments on my other PR before, but yeah I like your solution better. @eileenmcnaughton what kind of issues you had with open-ended arrays before ? do you remember? |
@omarabuhussein so the 'contribute_invoice_settings' is an example where someone put in an array & we spent a long time later splitting it out into settings. The settings form is the most obvious thing - but in general the settings logic is all around one key (with metadata to describe it) per setting |
Ok I can split it into a couple. I'd do at least one for the font, one for the chroot, one for remote_enable because it would be nice to turn that off for security reasons, and one for the log since otherwise I wouldn't have a unit test. I don't think the "default_XXX" ones are too useful because the page format setting pages in civi allow setting those anyway. |
cefc297
to
442be3b
Compare
Ok I've updated. I debated whether to put them on a UI form - the log file setting would be developers-only so I left it off the form, but the other three it seemed like something you'd want to set in the UI. It just makes that miscellaneous page even more miscellaneous, but that's where wkhtmltopdf is already. |
thanks @demeritcowboy - @omarabuhussein were you going to test this? |
@eileenmcnaughton will do, yes. Will try to test it tomorrow. |
I tested "DOMPDF Local Images Folder" and "DOMPDF Enable Remote Images" settings and both are working fine, but I could not manage to get the fonts working for some reason, it keeps showing up as "?". |
Thanks for testing. I just tried again and it worked for me. A couple possibilities:
|
I quickly redid the test with all of what you mentioned in mind but with no luck, I am on Drupal 7 BTW, I will spend more time (hopefully before Friday) to see why it is not working for me, but I am almost certain that it is something with my configs and not your solution, given that your solution is merely sets the domepdf option, so for it not to work is most likely a config problem rather than a code problem. |
Ok thanks. You can also PM me in chat.civicrm.org and we could see if we can solve it, or if you want to send me screenshots there I can take a look. |
merging as I agree this is likely config |
Thanks. I'll do a docs PR. |
Overview
https://lab.civicrm.org/dev/core/-/issues/2126
For space reasons the stock fonts included with dompdf in civi only include Helvetica, Times, etc..., which have some non-english characters like ü, but not cyrillic or other characters like д. Even if it included the whole dompdf tree like it does in drupal 8, it doesn't include a good font with CJK characters.
Another reason you might want to set one of the dompdf options is that after dompdf did a recent security update local images don't work if they're outside the dompdf folder (see e.g. #20047). FYI @omarabuhussein
This PR adds the settings to the Miscellaneous admin settings form. The log file one which is unlikely to be used by regular users you can set in civicrm.settings.php or via an extension.
Before
While you can add fonts into vendor/dompdf/dompdf/lib/fonts, they get wiped on upgrade.
After
Can add fonts that survive upgrade. Can set some other settings.
Technical Details
The list of available settings is in Options.php. As per comments below we're only supporting a few.
I couldn't really write a test to test additional fonts, but it tests the general ability to set settings.
Comments
I can make a docs PR to update https://docs.civicrm.org/installation/en/latest/general/unicode_pdf
Steps to reproduce
?
instead of the letters.Quickie steps to test the PR
Make a folder like sites/default/files/fonts
Grab the files DejaVuSans.ttf and DejaVuSans.ufm from https://github.com/dompdf/dompdf/tree/master/lib/fonts and put them in sites/default/files/fonts. Don't worry about the bold or other variations, but if you really wanted to you could test those.
Make a file in there called
dompdf_font_family_cache.php
which contains:(Note
$fontDir
is a php variable - don't replace it with a path just leave it as$fontDir
)At Administer - System Settings - Miscellaneous, set the full path to your font folder.
Now repeat the steps to reproduce above.
To install a full font from scratch involves another utility. I can reference it in the docs PR.