Skip to content
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

Printing edge case emails still does not always work #9853

Open
GVodyanov opened this issue Jul 15, 2024 · 3 comments · May be fixed by #10670
Open

Printing edge case emails still does not always work #9853

GVodyanov opened this issue Jul 15, 2024 · 3 comments · May be fixed by #10670
Assignees

Comments

@GVodyanov
Copy link
Contributor

GVodyanov commented Jul 15, 2024

Issue 1 - Chromium

Steps to reproduce

  1. Open a long email with images, EG from supabase, facebook, instagram.
  2. Click on print email or do ctrl + p in Chromium

Expected behavior

The email content should start at the start of the page

Actual behavior

image

The print preview shows something like this

Email error Chromium.pdf

Issue 2 - Firefox

Steps to reproduce

  1. Open any email while having a large screen size
  2. Click on print email or do ctrl + p in Firefox

Expected behavior

The email should take up the whole width of the page

Actual behavior

image

Email error Firefox.pdf

Note: zooming in a lot or zooming out a lot fixes this

Mail app version

Main

@GVodyanov
Copy link
Contributor Author

It might be useful to use this after the Vue 3 migration https://vue-to-print.netlify.app/

@SebastianKrupinski
Copy link
Contributor

It might be useful to use this after the Vue 3 migration vue-to-print.netlify.app

Soooo... why haven't you completed the V3 migration yet? 😆😆😆😆😆

@GVodyanov
Copy link
Contributor Author

GVodyanov commented Feb 16, 2025

Here are some notes on the topic in case anyone tries to dig into this again in the future:

  • Just printing the page with some custom CSS has issues. The main one has to do with the fact that the iframes that represent messages get cut off between pages, seeing as the browser isn't able to distinguish where one element starts or ends inside an iframe for some reason. This results in cut images and text over different PDF pages.

    • This is not considering the fact that the custom CSS has formatting issues. It requires hiding a lot of elements and that is often buggy, classes change, and different browsers do printing very differently.
  • Using the files_emailviewer app to generate the PDF is an idea, but I assume that most instances don't have it configured.

  • Using a library is an idea. html2pdf.js allows you to be able to convert a selected element in the DOM and its children into a PDF for printing. It however seems to have issues rendering iframes, even when directly selecting the iframe. jsPDF seems to be well-supported, but you basically have to rebuild the page manually in order to use it. This would require using lots of selectors that might break in the future. https://vue-to-print.netlify.app/ Might be a good solution, but it is only available for Vue3.

  • Solution which I ended up using in the end: You can extract the desired message iframe from the DOM and print that using a native browser function, iframe.contentWindow.print(). This requires overriding the native Ctrl + P with a custom function.

    • Downsides:
      • if you have a mail thread, the messages in the mail thread after the first one aren't properly rendered, so they won't have custom styling or images. I am not sure if we plan on changing this in the future.
      • information about the subject and participant have to be manually injected into the iframe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗️ In progress
3 participants