示例#1
0
        private void WriteBody(StreamInfo[] streams, string htmlBody)
        {
            var propertiesStream = streams.GetPropertiesStream();
            var bodyStream       = streams.GetRTFBodyStream();

            var rtfBody             = HtmlToRtfConverter.ConvertHtmlToRtf(htmlBody);
            var bodyBytes           = Encoding.ASCII.GetBytes(rtfBody);
            var bodyAndHeaderLength = BitConverter.GetBytes(bodyBytes.Length + 12); // 12 - {UncopressedSize:4}{Magic:4}{CRC32:4}
            var bodyLength          = BitConverter.GetBytes(bodyBytes.Length);
            var crc32 = CRC32.CalculateCRC32(bodyBytes);

            var bodyData = new List <byte>();

            bodyData.AddRange(bodyAndHeaderLength);
            bodyData.AddRange(bodyLength);
            bodyData.AddRange(new byte[] { 0x4D, 0x45, 0x4C, 0x41 }); // Magic number (0x414c454d) means RTF is not compressed
            bodyData.AddRange(BitConverter.GetBytes(crc32));
            bodyData.AddRange(bodyBytes);
            var bodyDataBytes = bodyData.ToArray();

            WriteBytesAndTruncate(bodyStream, bodyDataBytes);

            // Update stream info in properties
            var properties = GetBytes(propertiesStream);
            var bodyIndex  = properties.IndexOf(new byte[] { 0x09, 0x10 }); // BodyRTF tag

            if (bodyIndex == -1)
            {
                throw new ArgumentException($"Could not locate body index in properties stream. BIdx: {bodyIndex};");
            }

            var fullBodyLength = BitConverter.GetBytes(bodyDataBytes.Length);

            WriteBytes(propertiesStream, fullBodyLength, bodyIndex + StreamSizeOffset);
        }
示例#2
0
        static void convertHtmlToRtf(object arg)
        {
            StringBuilder buffer = (StringBuilder)arg;
            string        rtf    = HtmlToRtfConverter.ConvertHtmlToRtf(buffer.ToString());

            buffer.Clear();
            buffer.Append(rtf);
        }
示例#3
0
 private void ApplyQueryEditor(string text)
 {
     QueryEditor.Rtf = HtmlToRtfConverter.ConvertHtmlToRtf(text);
     QueryEditor.SelectAll();
     QueryEditor.SelectionFont = QueryFont;
     QueryEditor.DeselectAll();
     QueryEditor.SelectionStart = CursorPosition;
 }
示例#4
0
        private void HomeDashboard_Load(object sender, EventArgs e)
        {
            var message = "<p style=\"font-family:verdana;font-size:6;\"><p>Welcome to eBatch Application.</p><br><br> hi User, Good Morning.<br><br>                    " +
                          "<p><strong>Messages:</strong></p> <br>                                                    " +
                          "<p><span style=\"text - decoration: underline; \">13 Nov 2018:</span></p>                  " +
                          "<p style=\"padding - left: 30px; \">3 Invoices been assigned to you by Admin.</p>          " +
                          "<p style=\"padding - left: 30px; \">10 Invoices been sent to disbursement</p> <br>             " +
                          "<p><span style=\"text - decoration: underline; \">12 Nov 2018:</span></p>                  " +
                          "<p style=\"padding - left: 30px; \">13 Invoices been assigned to you by Admin.</p>         " +
                          "<p style=\"padding - left: 30px; \">15&nbsp;Invoices been sent to disbursement</p>         " +
                          "<p>&nbsp;</p>" +
                          "<p>&nbsp;</p></p>";



            string rtfString = HtmlToRtfConverter.ConvertHtmlToRtf(message);

            richTextBox1.Rtf = rtfString;
            ManageTileColor();
        }
 public string ConvertHtmlToRtf(string htmlText)
 {
     return(_aHtmlToRtfConverter.ConvertHtmlToRtf(htmlText));
 }