GitHub user dosubot[bot] added a comment to the discussion: In Apache Superset,
to include a logo in PDF/email reports, does it require frontend code change?
<!-- Answer -->
To add a logo to PDF/email reports in Apache Superset, you need to modify the
backend code in the `superset/utils/core.py` file. Specifically, you can use
the `MIMEImage` class to attach the logo image as an inline image in the email.
Here's a general approach:
1. **Import the Image**: Ensure the image you want to include is accessible in
your environment.
2. **Modify the Code**: Locate the section where images are attached to the
email using `MIMEImage`. You can add your logo image in a similar manner.
Here's a simplified example:
```python
from email.mime.image import MIMEImage
# Load your logo image data
with open('path/to/logo.png', 'rb') as img_file:
logo_data = img_file.read()
# Create a MIMEImage object for the logo
logo_image = MIMEImage(logo_data, name='logo.png')
logo_image.add_header("Content-ID", "<logo>")
logo_image.add_header("Content-Disposition", "inline")
# Attach the logo image to the email message
msg.attach(logo_image)
```
3. **Reference the Logo in HTML**: In the HTML content of the email, reference
the logo using its `Content-ID`:
```html
<img src="cid:logo" alt="Logo">
```
Make sure to adjust the file path and name according to your setup. This change
should be made in the backend code, and no frontend code changes are necessary
for this task
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/utils/core.py)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=hallucination)
| [Bug
Report](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/c397c46e-e7e7-4ab2-9807-42c6de3fa659?feedback_type=other)</sup>
GitHub link:
https://github.com/apache/superset/discussions/33416#discussioncomment-13126506
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]