M
M
Mozzarella2018-03-17 21:32:18
HTML
Mozzarella, 2018-03-17 21:32:18

How to convert HTML to DOCX C#?

My WPF application generates code in XAML format using a WYSWIG editor, then I convert it to HTML, in order to further convert HTML format to DOCX, I use this library . But in the end, all styles except alignment are reset. Are there any other ways? Generated HTML Example

<DIV STYLE="text-align:Left;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:12;color:#000000;"><P
            STYLE="font-family:roboto;font-size:14;margin:0 0 0 0;"><SPAN
                STYLE="font-style:italic;font-weight:bold;text-decoration:underline;"><SPAN>asdas</SPAN></SPAN></P>
    <P STYLE="text-align:Right;font-family:tahoma;font-size:14;margin:0 0 0 0;"><SPAN
                STYLE="font-weight:bold;"><SPAN>as</SPAN></SPAN></P>
    <P STYLE="text-align:Right;font-family:tahoma;font-size:14;margin:0 0 0 0;"><SPAN
                STYLE="font-weight:bold;color:#E12C2C;"><SPAN>asdasdsad</SPAN></SPAN></P>
    <UL STYLE="margin:0 0 0 0;padding:0 0 0 0;">
        <LI STYLE="margin:0 0 0 24;"><P STYLE="text-align:Right;font-family:tahoma;font-size:14;margin:0 0 0 0;"><SPAN
                        STYLE="font-weight:bold;color:#E12C2C;"><SPAN>ss</SPAN></SPAN></P></LI>
        <LI STYLE="margin:0 0 0 24;"><P STYLE="text-align:Right;font-family:tahoma;font-size:14;margin:0 0 0 0;"><SPAN
                        STYLE="font-weight:bold;color:#E12C2C;"><SPAN>sdfsdf</SPAN></SPAN></P></LI>
        <LI STYLE="margin:0 0 0 24;"><P STYLE="text-align:Right;font-family:tahoma;font-size:14;margin:0 0 0 0;"><SPAN
                        STYLE="font-weight:bold;color:#E12C2C;text-decoration:underline;"><SPAN>sfsdfsd</SPAN></SPAN>
            </P></LI>
    </UL>
</DIV>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Yudakov, 2018-03-17
@AlexanderYudakov

No html needed here.
Write the FlowDocument -> docx converter right away.
Here is a library for working with docx:
https://github.com/xceedsoftware/DocX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question