.NET Interface

The .NET Interface makes it possible for Docx to HTML V2.0 to function through .NET applications developed using Visual Basic.NET, Visual C#.NET and similar programs.

Windows version

Linux version

CAUTION: You cannot have both Docx to HTML V2.0 and another version of Docx to HTML installed on your machine when the NET interface is used. It is necessary to uninstall one version, or only set the path of Docx to HTML you want to use by deleting the unwanted path from the environment variables.

Component Registration

Docx to HTML .NET component is not registered automatically to the global assembly cache (GAC). It is necessary to create the path either by putting the .NET component in the current folder of the application, or by creating an application configuration file.

.NET Component File Name for .NET 8DhcDotNetMCtl20.dll

Classes

The following classes are contained in the .NET component:

Name Functions
DhcObj Docx to HTML V2.0 class (itself). DhcObj

Example for C#

DhcObj adhc = new(); try { // some process } catch (Exception e) { Console.WriteLine(e.Message); }

Methods

DhcObj Class provides the following methods:

Name Return Value Arguments Functions
execute None None Executes the conversion and outputs to the destination specified in setDocumentURI .
setDocumentURI None newVal : string Specify the input file name.
newVal
Specify the input file path.
setOutputFilePath None newVal : string Specify the output file name.
newVal
Specify the output file path.
clrSettings None None Clears option settings.
lodeSettings None newVal : string Loads specified option setting file.
newVal
Specify the conversion option setting file path.
setEnableXHTML None newVal : bool Specifies the grammar for tag output.
newVal
If "true", specified XML grammar. If "false", specified HTML grammar.
setViewportContent None content : string Specifies to output the meta tag in the following format in the <head>.
<meta name="viewport" content=" Content specified in ‘content’">
content
Specify the attribute value to be entered in the content attribute.
setEnableENDL None newVal : bool Specifies whether to output a line break at the end of the block tag.
newVal
If "true", specifies output. If "false", specifies.
setEnableEmptyParagraph None newVal : bool blank lines (lines with line breaks only) in Word.
newVal
If "true", ignored blank lines. If "false", outputs empty <p> tags as many as the number of blank lines.
setEnableNonRefId None newVal : bool While editing in Word, a lot of IDs that are not internally deleted may be created.
Specifies whether these internally unreferenced IDs should be removed in HTML output.
setEnableImgWidth None newVal : bool Specifies whether to output the width of the image.
newVal
If "true", specifies to output. If "false", specifies not to output.
setEnableHeadingStrong None newVal : bool Specifies whether to ignore the emphasis specified in the heading style.
newVal
If "true", specifies to ignore. If "false", specifies to output.
setEnableEmbedimage None newVal : bool Specifies whether to embed the image in the body HTML as a data URL.
newVal
If "true", specifies to embed the image. If "false", specifies images are output to the image folder.
setEnableMathML None newVal : bool Specifies whether to output to <img> tags in MathML format for formulas edited in the Word Equation Editor.
newVal
If "true", specifies to output. If "false", specifies not to output.
setXmlMathML None newVal : bool Specifies whether to output to MathML formatted markup for formulas edited in the Word Equation Editor.
newVal
If "true", specifies to output. If "false", specifies not to output.
setOMath None newVal : bool Specifies whether to output to Word's own Office Math format for formulas edited in the Word Equation Editor.
newVal
If "true", specifies to output. If "false", specifies not to output.
setThroughImage None newVal : bool Specifies whether to output the image in its original format inserted into Word.
newVal
If "true", specifies to output. If "false", specifies not to output.
setEnablePStyle None newVal : bool Specifies whether to output the style name of the paragraph by setting it as the value of the class attribute.
newVal
If "true", specifies to output. If "false", specifies not to output.
setEnableCitation None newVal : bool Specifies whether to outputs the value of tag in the Citation field by setting it as the value of the href attribute of the <a> tag.
newVal
If "true", specifies to output. If "false", specifies not to output.
setTextColor None newVal : bool Specifies whether to outputs the color specified for the text as <span style="color:color value">.
newVal
If "true", specifies to output. If "false", specifies not to output.
setItalic None newVal : int Specifies the output method when italics are specified for text.
newVal
Italic output method.
0 : Do not output. (default)
1 : Output as <i>tag.
2 : Output as <span style="font-style:italic">
setUnderline None newVal : int Specifies the output method when underline is specified for text.
newVal
underline output method.
0 : Do not output. (default)
1 : Output as <u>tag.
2 : Output as <span style="text-decoration-line:underline;">
setLinethrough None newVal : int Specifies the output method when strikethrough is specified for text.
newVal
strikethrough output method.
0 : Do not output. (default)
1 : Output as <del>tag.
2 : Output as <span style="text-decoration-line: line-through;">
setEncoding None newVal : string Specifies the character code (encoding method) of the HTML file. (default : "UTF-8")
newVal
Specifies the character code.
setDefstyle None newVal : bool Specifies whether to output the <style> element (element specifying the default CSS style) in <head>.
newVal
If "true", specifies not to output. If "false", specifies to output.
setSpaceIndent None newVal : bool Specifies whether to convert the indentation to a a single full-width space when one or more characters of indentation are specified at the beginning of the paragraph.
newVal
If "true", specifies to convert. If "false", specifies not to convert.
setOutputBR None newVal : bool Specifies whether to output <br> tags at the end of paragraphs instead of enclosing them in <p> tags.
It is invalid when XML grammar is specified in tag output.
newVal
If "true", specifies to output <br> tags. If "false", specifies to output <p> tags.
setFileimages None newVal : bool Specifies how to name the folder that stores image files.
newVal
If "true", specifies as "destination_file_name.image". If "false", specifies as "image".
setCSS None uri : string
media : string
Specifies the CSS file to link.
uri
Specifies the CSS file path.
media
You can optionally specify media.
setJS None newVal : string Place the script tag in <head> and specify the path (URL) of the JavaScript file in its src attribute.
newVal
Specified the path of the JavaScript file.
saveSettings None newVal : string Specify the path of the option setting file.
setTablestyle None newVal : bool Specifies whether to output the table-style.
newVal
If "true", specifies to output. If "false", specifies not to output.
setSplit None newVal : int You can specify the outline level at which HTML <section> (or <div class=‘section-area’>) tags are output.
newVal
Outline level can be specified from 1 to 3.
setEnableTocout None newVal : bool When "setSplit" is called, the table of contents inserted by the Word table of contents function is output as a separate HTML file (inc-toc.html).
The inc-toc.html file can be included in the split HTML file using JavaScript. inc-toc.html does not output tags such as <head> and <body> other than the tags for the table of contents.
Please refer to the following web page for a sample of how to include a table of contents using JavaScript.
https://www.antennahouse.com/html-on-word-samples
newVal
If true is specified, output as a separate HTML file (inc-toc.html). If false, the table of contents will be output at the top of all the split HTML files.
setPagenavi None newVal : string You can specify the outline level at which HTML <section> (or <div class=‘section-area’>) tags are output.
newVal
If "ja" is specified, "前へ" and "次へ" links will be output in Japanese.
If you specify anything other than "ja", "Prev" and "Next" links will be output in English.
If the previous or next page does not exist, each link is omitted.
setLang None newVal : string You can specify the language (lang attribute) to be output in the <html> tag of the output HTML file.
newVal
Specify the language code. (e.g. "ja" for Japanese, "en" for English.)
If "none" is specified for, the lang attribute is not output to the <html> tag.
If values other than single-byte alphanumeric characters or single-byte hyphens are specified, "ja" (Japanese) or "en" (English) is output, inferred from the Word document.
If the "setEnableXHTML" parameter is called, the language code specified for the xml:lang attribute and lang attribute of the <html> tag, respectively, is output.
Example: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
setSection None newVal : int You can specify the outline level at which HTML <section> (or <div class=‘section-area’>) tags are output.
newVal
By specifying 1 to 6 numbers (integers) following, <section> up to the specified outline level are output.
If anything other than 1 to 6 is specified, it is equivalent to specifying "6". For example, if you do not want to output <section> tags below outline level 4, specify "3".
setEndnoteId None newVal : bool When inserting endnotes in a Word document, if the start number of the sequential number of the endnote is set to a number other than ‘1’, you can match the number of the endnote character (<sup> tag) in the output HTML and the number used at the end of the ‘id’ specifying the endnote.
newVal
If "true", it is enabled. If "false", it is disabled.
setFootnote None newVal : int Specifies how footnotes are output to html when they are present in a Word document.
newVal
Specifies how footnotes are output to html.
0 : Output footnotes at the end of a sentence (or at the end of the last sentence in the last HTML file if the HTML is split into separate HTML files), so that the hyperlink given to the reference mark in the text can be used to navigate to the corresponding footnote. (Default) Footnotes are output enclosed in <aside> tags. If the true is specified for the "setEnableXHTML" argument, the output is enclosed in <div> tags.
Note: If "0" is specified, endnotes are output in the same way.
1 : Add a <span> tag to a reference mark in the body text, output the text of the corresponding footnote in the value of the “title” attribute, and display a tooltip on mouseover of the reference mark.
2 : Footnotes and footnote reference marks are not output.
setCustomSep None newVal : bool If footnotes and endnotes are inserted, specifies the boundaries with the body text.
newVal
If true is specified, all boundaries are output as <hr> tags by default. You can output text strings or tables edited in Word. If boundaries are included, they are output with <span> tags instead of <hr> tags. If "false", specifies to output.

Running the Sample Program

[Install directory]/​samples/​dotnet includes simple sample programs.

To run this sample program in the [Working directory], do the following:
Copy the directory under samples to [Working directory]. At this time, copy the DhcDotNetMCtl20.dll to the [Working directory]/​​samples/​​dotnet.

> cd [Working directory]/samples/dotnet > dotnet build sample.csproj > dotnet run ../sample.docx sample.html