Problem/Motivation
When I updated the DomPDF library to v0.8.6 I suffer some problems with relative images, searching on dompdf, aparently DomPDF does not support internal images. This same problem exists for v0.8.0+ when using S3 as the Drupal file system.
- https://stackoverflow.com/questions/25558449/dompdf-image-not-readable-o...
- https://github.com/dompdf/dompdf/issues/1523
Steps to reproduce
Use a relative internal image path on /admin/commerce/config/billy-invoice/pdf Logo section. For example "/sites/all/themes/custom/my_theme/images/pdf-logo.jpg". Or, use a full path to an image hosted on AWS S3 when the Drupal file system has been replaced with the s3fs module.
Proposed resolution
Determine if the invoice logo file exists, and its proper path based on the relative or full path entered into the settings configuration. If it does exist, retrieve its contents through base64 encoding. If it does not exist, display no logo and write an error message to watchdog.
Comments
Comment #2
eduardo morales albertiUpdated patches for 7.x-1.3 and 7.x-1.x with the changes necessary to work images with v0.8.0+ versions.
Comment #3
eduardo morales albertiReupload patch changing logo image to base64.
Comment #4
4kant commentedThanks Eduardo,
patch in #3 works for me! ;-)
Comment #5
shaneonabike commentedI can confirm that this issue is working properly. It would be great if this could be included in a release.
Comment #6
klausiThanks, I think the approach makes sense. I like the base64 encoding more than allowing remote files.
There should be an empty line after the @param section
we should first check if the file exists and only then do the base64 encoding. We should write a watchdog error if the file does not exist.
We also don't want to support remote files for security reasons, so the file_exists() check is correct.
Can you update the issue summary and fix the minor things I found?
Comment #7
sgdev commentedI have created a revised patch for review and an interdiff. I will also update the issue summary.
Per this patch I wrote in 2019 (https://www.drupal.org/project/commerce_billy/issues/3081653), there is also a critical 0.8.0+ issue with the invoice logo that does not allow it to work when the local file system has been replaced with S3, as is the case for our sites.
Given it is clear from this thread that the wish is to avoid the use of
isRemoteEnabled, the patch in #3 has been modified to include @klausi's recommendations, and to support the use of full paths that reconcile with available Drupal file system schemes. Therefore, users can enter relative paths, and paths that are prefixed byhttps://,public://,s3://, etc., as long as the path reconciles to a Drupal scheme.Please review and let me know your feedback, thank you.
Comment #8
sgdev commentedComment #9
klausiThanks Ron, very sorry to bump this back again.
I think we should not mix 2 issues here. The S3 and other file system support should be a separate issue. Let's fix the simple base64 approach here first to get that out of the way.
So we should have a relatively short patch hear based on Eduardo's patch above.
Comment #10
sgdev commented@klausi, that's fine. Was trying to incorporate both since I'm always concerned when will be the next time someone might look at these old patches and make a commit.
I'll re-roll the patch, and open the other issue with a separate patch for S3.
Comment #11
sgdev commentedSee attached patch and interdiff, thanks.
Comment #13
klausiThanks!
this will create double em tags, the %placeholder already adds them.
Fixed that and committed it!