예제 #1
0
        private static object FromRtfToHtml(ICoreItem coreItem, BodyReadConfiguration configuration, Stream bodyStream, bool createReader)
        {
            object obj    = null;
            Stream stream = null;

            try
            {
                stream = new ConverterStream(bodyStream, new RtfCompressedToRtf(), ConverterStreamAccess.Read);
                RtfToHtml rtfToHtml = new RtfToHtml();
                rtfToHtml.OutputEncoding     = configuration.Encoding;
                rtfToHtml.Header             = configuration.InjectPrefix;
                rtfToHtml.Footer             = configuration.InjectSuffix;
                rtfToHtml.HeaderFooterFormat = configuration.InjectionHeaderFooterFormat;
                rtfToHtml.FilterHtml         = configuration.FilterHtml;
                rtfToHtml.HtmlTagCallback    = configuration.InternalHtmlTagCallback;
                rtfToHtml.OutputHtmlFragment = configuration.IsHtmlFragment;
                if (configuration.StyleSheetLimit != null)
                {
                    TextConvertersInternalHelpers.SetSmallCssBlockThreshold(rtfToHtml, configuration.StyleSheetLimit.Value);
                }
                obj = BodyReadDelegates.GetTextStreamOrReader(stream, rtfToHtml, createReader);
            }
            finally
            {
                if (obj == null && stream != null)
                {
                    stream.Dispose();
                    stream = null;
                }
            }
            return(obj);
        }
예제 #2
0
        private static object FromHtmlToHtml(ICoreItem coreItem, BodyReadConfiguration configuration, Stream bodyStream, bool createReader)
        {
            Charset    itemMimeCharset = ConvertUtils.GetItemMimeCharset(coreItem.PropertyBag);
            Charset    charset         = configuration.Charset;
            HtmlToHtml htmlToHtml      = new HtmlToHtml();

            htmlToHtml.InputEncoding             = itemMimeCharset.GetEncoding();
            htmlToHtml.OutputEncoding            = charset.GetEncoding();
            htmlToHtml.Header                    = configuration.InjectPrefix;
            htmlToHtml.Footer                    = configuration.InjectSuffix;
            htmlToHtml.HeaderFooterFormat        = configuration.InjectionHeaderFooterFormat;
            htmlToHtml.DetectEncodingFromMetaTag = false;
            htmlToHtml.FilterHtml                = configuration.FilterHtml;
            htmlToHtml.HtmlTagCallback           = configuration.InternalHtmlTagCallback;
            htmlToHtml.OutputHtmlFragment        = configuration.IsHtmlFragment;
            if (configuration.StyleSheetLimit != null)
            {
                TextConvertersInternalHelpers.SetSmallCssBlockThreshold(htmlToHtml, configuration.StyleSheetLimit.Value);
            }
            return(BodyReadDelegates.GetTextStreamOrReader(bodyStream, htmlToHtml, createReader));
        }