Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmail html preview removes css rule with page-break property

we are sending html page as attachment to our users which they can use to print. When you view the html page using gmail in browser it removes any css rule with page-break-after property.

We want to force page-break for printing.

What is the work around for this.

like image 810
user1271519 Avatar asked Oct 08 '22 03:10

user1271519


2 Answers

Nothing you can do about it. As explained by chipcullen Gmail strips out all CSS in webpage except the one inside the HTML tags, and even with those it does strange stuff like removing the page-break-after attributes.

The only workaround I can think about is to keep the html file or your server and simply send a link to it in your mail message in place of the attachement.

Great is the mistery surrounding these type of decisions made by Google engineers. Maybe they want users to go back using Outlook. Well, they almost convinced me.

like image 99
Marco Demaio Avatar answered Oct 12 '22 19:10

Marco Demaio


I can't say about the page-break-after property specifically, but I do know that Gmail does WEIRD things to CSS in HTML emails. For instance, Gmail will strip out any CSS that is either in the <head> or inline with the <body> tag. You will have to apply your rule inline.

From what it sounds like, you're relying more on the browser to render the attachment, and the user is printing from there. Are you sure page-break-after is supported in your test browser?

like image 31
chipcullen Avatar answered Oct 12 '22 20:10

chipcullen