public void TestMethod() { string path = Assembly.GetExecutingAssembly().Location; path = path.Remove(path.LastIndexOf('\\')); string flowdoc = GetFileContent(path + "\\FlowDoc.xml"); TagConverter converter = new Document(); string result = converter.ConvertToHtml(flowdoc); Assert.IsNotNull(result); }
static TagConverter() { TagConverter document = new Document(); TagConverter paragraph = new Paragraph(); TagConverter span = new Span(); TagConverter blod = new Blod(); TagConverter linkbreak = new LineBreak(); TagConverter underline = new UnderLine(); TagConverter hyperlink = new Hyperlink(); TagConverter list = new List(); TagConverter listitem = new ListItem(); TagConverter table = new Table(); TagConverter tablerow = new TableRow(); TagConverter tablecell = new TableCell(); TagConverter run = new Run(); #region FlowDoc to Html // Flow attribute tag converter TagAttributeConverter textDecorations = new TextDecorations(); TagValueConverter textDecoration = new TextDecoration(); TagAttributeConverter margin = new Margin(); TagValueConverter thickness = new Thickness(); // Init flow tag mapping RegisterFlowToHtmlTagConverter(Tags.FLOW_FLOW_DOCUMENT, document); RegisterFlowToHtmlTagConverter(Tags.FLOW_PARAGRAPH, paragraph); RegisterFlowToHtmlTagConverter(Tags.FLOW_SPAN, span); RegisterFlowToHtmlTagConverter(Tags.FLOW_RUN, run); RegisterFlowToHtmlTagConverter(Tags.FLOW_BLOD, blod); RegisterFlowToHtmlTagConverter(Tags.FLOW_LINE_BREAK, linkbreak); RegisterFlowToHtmlTagConverter(Tags.FLOW_UNDER_LINE, underline); RegisterFlowToHtmlTagConverter(Tags.FLOW_HYPER_LINK, hyperlink); RegisterFlowToHtmlTagConverter(Tags.FLOW_LIST, list); RegisterFlowToHtmlTagConverter(Tags.FLOW_LIST_ITEM, listitem); // Table / TableRow / TableCell RegisterFlowToHtmlTagConverter(Tags.FLOW_TABLE, table); RegisterFlowToHtmlTagConverter(Tags.FLOW_TABLE_ROW, tablerow); RegisterFlowToHtmlTagConverter(Tags.FLOW_TABLE_CELL, tablecell); // TextDecorations / TextDecoration RegisterFlowToHtmlTagConverter(Attributes.FLOW_TAG_TEXT_DECORATIONS, textDecorations); RegisterFlowToHtmlTagConverter(Tags.FLOW_TEXT_DECORATION, textDecoration); // Margin / Thickness RegisterFlowToHtmlTagConverter(Attributes.FLOW_TAG_MARGIN, margin); RegisterFlowToHtmlTagConverter(Tags.FLOW_THICKNESS, thickness); #endregion #region Html to FlowDoc HtmlHeader header = new HtmlHeader(); RegisterHtmlToFlowTagConverter(Tags.HTML_H1, header); RegisterHtmlToFlowTagConverter(Tags.HTML_H2, header); RegisterHtmlToFlowTagConverter(Tags.HTML_H3, header); RegisterHtmlToFlowTagConverter(Tags.HTML_H4, header); RegisterHtmlToFlowTagConverter(Tags.HTML_H5, header); RegisterHtmlToFlowTagConverter(Tags.HTML_H6, header); // Init html tag mapping //RegisterHtmlToFlowTagConverter(Tags.HTML_P, paragraph); //RegisterHtmlToFlowTagConverter(Tags.HTML_SPAN, span); //RegisterHtmlToFlowTagConverter(Tags.HTML_B, blod); //RegisterHtmlToFlowTagConverter(Tags.HTML_BR, linkbreak); //RegisterHtmlToFlowTagConverter(Tags.HTML_U, underline); //RegisterHtmlToFlowTagConverter(Tags.HTML_A, hyperlink); //RegisterHtmlToFlowTagConverter(Tags.HTML_UL, list); //RegisterHtmlToFlowTagConverter(Tags.HTML_LI, listitem); //RegisterHtmlToFlowTagConverter(Tags.HTML_TABLE, table); //RegisterHtmlToFlowTagConverter(Tags.HTML_TR, tablerow); //RegisterHtmlToFlowTagConverter(Tags.HTML_TD, tablecell); #endregion }