Кодеки: Как преобразовать HTML в DOCX?
В этом разделе
SDK может сконвертировать HTML документ в DOCX документ.
SDK поддерживает следующие HTML-теги:
a, abbr, acronym, area, article, b, base, basefont, big, blockquote, body, br, caption, center, circle, clipPath, code, col, colgroup, dd, defs, div, dl, dt, ellipse, em, embed, fieldset, figcaption, figure, font, footer, form, frame, g, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, image, img, input, isindex, label, legend, li, line, linearGradient, link, map, marker, mask, meta, noscript, object, ol, optgroup, option, p, param, path, polygon, polyline, pre, q, rect, s, script, section, select, small, span, stop, strike, strong, style, sub, sup, svg, table, tbody, td, text, textarea, tfoot, th, thead, title, tr, tspan, tt, u, ul, use
.
SDK поддерживает следующие CSS-атрибуты:
align-items, background, background-attachment, background-color, background-image, background-position, background-position-x, background-position-y, background-repeat, border, border-bottom, border-bottom-color, border-bottom-left-radius, border-bottom-right-radius, border-bottom-style, border-bottom-width, border-collapse, border-color, border-left, border-left-color, border-left-style, border-left-width, border-radius, border-right, border-right-color, border-right-style, border-right-width, border-style, border-top, border-top-color, border-top-left-radius, border-top-right-radius, border-top-style, border-top-width, border-width, bottom, clip-path, clip-rule, color, column-gap, content, cx, cy, d, display, fill, fill-opacity, fill-rule, flex-direction, flex-wrap, float, font, font-family, font-size, font-style, font-variant, font-weight, gap, height, justify-content, left, letter-spacing, line-height, list-style-type, margin, margin-block, margin-block-end, margin-block-start, margin-bottom, margin-inline, margin-inline-end, margin-inline-start, margin-left, margin-right, margin-top, marker, marker-end, marker-mid, marker-start, mask, opacity, order, padding, padding-bottom, padding-inline, padding-inline-end, padding-inline-start, padding-left, padding-right, padding-top, page-break-before, position, r, right, row-gap, rx, ry, stop-color, stop-opacity, stroke, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit, stroke-opacity, stroke-width, table-layout, text-align, text-anchor, text-decoration, text-decoration-color, text-decoration-line, text-decoration-style, text-decoration-thickness, text-indent, text-transform, text-wrap-mode, top, transform, vertical-align, white-space, white-space-collapse, width, x, y, z-index
.
Вот C#/VB.NET код, который показывает, как преобразовать HTML документ в DOCX документ:
/// <summary>
/// Converts HTML document to a DOCX document.
/// </summary>
/// <param name="htmlFilePath">Path to a source HTML file.</param>
/// <param name="docxFilePath">Path to a result DOCX file.</param>
public static void ConvertHtmlToDocx(string htmlFilePath, string docxFilePath)
{
Vintasoft.Imaging.Office.OpenXml.OpenXmlDocumentConverter.ConvertHtmlToDocx(htmlFilePath, docxFilePath);
}
''' <summary>
''' Converts HTML document to a DOCX document.
''' </summary>
''' <param name="htmlFilePath">Path to a source HTML file.</param>
''' <param name="docxFilePath">Path to a result DOCX file.</param>
Public Shared Sub ConvertHtmlToDocx(htmlFilePath As String, docxFilePath As String)
Vintasoft.Imaging.Office.OpenXml.OpenXmlDocumentConverter.ConvertHtmlToDocx(htmlFilePath, docxFilePath)
End Sub