salesagility / SuiteCRM-Core

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

Images from Records do not show in PDF Templates #96

Open pstevens71 opened 2 years ago

pstevens71 commented 2 years ago

Issue

When you create a record and include an image field and then create a PDF template to display that image, the image is blank. It works in SuiteCRM 7, this is an 8 issue only.

Expected Behavior

The image field from the record should display in the associated PDF Template.

Actual Behavior

What happens is a blank appears where the image is supposed to be.

Possible Fix

The issue is that templateParser.php is looking for the file in /public/ when now in SuiteCRM 8 the URL should be /public/legacy/public/

Changing:

$secureLink = $sugar_config['site_url'] . '/' . "public/" . $focus->id . '_' . $fieldName; TO:

$secureLink = $sugar_config['site_url'] . '/' . "public/legacy/public/" . $focus->id . '_' . $fieldName;

in /legacy/modules/AOS_PDF_Templetes/templateParser.php

solves the problem and images now display in PDF templates

Steps to Reproduce

  1. Create an image field in a legacy module (images don't work at all in SuiteCRM 8 that's another issue)
  2. Create a PDF Template that contains that image
  3. Try to print the PDF
  4. No images appear

Context

Your Environment

RickfiregamesPT commented 3 months ago

Hey Stevens, you have been a great help for me first of all. You helped me alot across the SuiteCRM journey.

Can you check if all images are not showing in the pdf?

I was facing the same issue for 3 months but now figured it out.

Can you activate the logs in the TCPDF Engine?

/bitnami/suitecrm/public/legacy/vendor/tecnickcom/tcpdf/config/tcpdf_config.php

And add:

define(‘K_TCPDF_THROW_EXCEPTION_ERROR’, true);

And check the apache logs after generating the pdf.

Might be permissions issues in /opt/bitnami/php/tmp

After chown'ing all files to daemon:daemon it worked.

Please try and check if it fixes the issue.

Really looking forward to hear from you.

pstevens71 commented 3 months ago

This is an old one. I do have a fix above, don't know if that has been fixed since. I tried to test, but looks like another bug. I added an Image field to Accounts so I could test the PDF, but the image field doesn't render properly. I renders as a text field and I can't upload an image. I pretty much stick to SuiteCRM 7 these days. There are just too many of these kinds of problems everywhere. Hoping they extend the roadmap for SuiteCRM 7 support for another few years.

image

RickfiregamesPT commented 3 months ago

Oh ok, do you reckon i should pull this issue then in another thread?

pstevens71 commented 3 months ago

Do you have the same issue with adding images in the first place to the record? Is so, yes.

I think what I had to do, if memory served me correctly, there were two issues, one, the image field didn't work so I changed the module back to a Legacy Module. Which allowed the image field to work. Then I had to adjust where the PDF template get's the image from (url) as noted above.

RickfiregamesPT commented 3 months ago

The thing is for default the bitnami stack uses legacy, the issue i was facing was the images in the pdf template( in this case https://www.url.com/legacy/themes/default/images/company_logo.png) at the start of the template was showing in the template itself for example invoice template, but printing the Invoice doesn't display the image.

I was experimenting in changing the PDF Engine when i activated the logs from it and found the issue itself.

In the Templates images are shown but the Engine itself doesn't append the images in the pdf due to the permissions error. Notice also this was a fresh install of SuiteCRM 8.5.1