Sicos1977 / MSGReader

C# Outlook MSG file reader without the need for Outlook
http://sicos1977.github.io/MSGReader
MIT License
478 stars 168 forks source link

Add support for custom CSS for Header. #239

Closed easyjoh closed 3 years ago

easyjoh commented 3 years ago

Fixes #238

Added a proposed way to allow custom CSS for the HTML header.

The implementation does not alter the parameters of the functions and, thus, should remain full backward comptibility without any change to the style or functionality.

Enabling custom CSS for the (tested using MsgViewer):

                Reader.UseCustomHeaderStyle = true;

                Reader.SetCustomHeaderStyle(
                    "table.MsgReaderHeader {" +
                    "   font-family: Arial;" +
                    "   font-size: 12pt;" +
                    "   width: 100%;" +
                    "   border-top: 3px solid black;" +
                    "}\n" +
                    "tr.MsgReaderHeaderRow {" +
                    "   height: 18px; vertical-align: top;" +
                    "}\n" +
                    "tr.MsgReaderHeaderRowEmpty {}\n" +
                    "td.MsgReaderHeaderRowLabel {" +
                    "   font-weight: bold; white-space:nowrap;" +
                    "   padding-right: 170px;" +
                    "}\n" +
                    "td.MsgReaderHeaderRowText {}\n" +
                    "div.MsgReaderContactPhoto {" +
                    "   height: 250px; position: absolute; top: 20px; right: 20px;" +
                    "}\n" +
                    "div.MsgReaderContactPhoto > img {" +
                    "   height: 100%;" +
                    "}\n" +
                    "table.MsgReaderInlineAttachment {" +
                    "   width: 70px; display: inline; text-align: center; font-family: Arial; font-size: 12pt;" +
                    "}"
                    );

You could consider to use the above stylesheet as default as it is a bit closer to the output of Outlook.

Let me know if you have any comments.

Sicos1977 commented 3 years ago

I shall see what I do, when I made the headers years back it was the closest to Outlook that I could come on that moment.

easyjoh commented 3 years ago

I found this style better (small amendment to above proposal):

                Reader.UseCustomHeaderStyle = true;

                Reader.SetCustomHeaderStyle(
                    "table.MsgReaderHeader {" +
                    "   font-family: Arial;" +
                    "   font-size: 12pt;" +
                    "   width: 100%;" +
                    "   border-top: 3px solid black;" +
                    "   padding-top: 5px;" +
                    "}\n" +
                    "tr.MsgReaderHeaderRow {" +
                    "   height: 18px; vertical-align: top;" +
                    "}\n" +
                    "tr.MsgReaderHeaderRowEmpty {}\n" +
                    "td.MsgReaderHeaderRowLabel {" +
                    "   font-weight: bold; white-space:nowrap;" +
                    "   padding-right: 100px;" +
                    "}\n" +
                    "td.MsgReaderHeaderRowText {" +
                    "   width: 100%;" +
                    "}\n" +
                    "div.MsgReaderContactPhoto {" +
                    "   height: 250px; position: absolute; top: 20px; right: 20px;" +
                    "}\n" +
                    "div.MsgReaderContactPhoto > img {" +
                    "   height: 100%;" +
                    "}\n" +
                    "table.MsgReaderInlineAttachment {" +
                    "   width: 70px; display: inline; text-align: center; font-family: Arial; font-size: 12pt;" +
                    "}"
                );