Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{description}
{excerpt}Processes the XHTML string and inserts it into the specified Word document as formatted text after the given WordWriter Element using the given NamedStyle. Returns the last [Element|Element] inserted into the document.{excerpt}
{signature:C#}
public SoftArtisans.OfficeWriter.WordWriter.Element InsertHTML(System.String xhtml, SoftArtisans.OfficeWriter.WordWriter.Document doc, SoftArtisans.OfficeWriter.WordWriter.NamedStyle style, SoftArtisans.OfficeWriter.WordWriter.Element insertAfterElement)
{signature}{signature:vb.net}
Public Function InsertHTML(ByVal xhtml As String, ByVal doc As SoftArtisans.OfficeWriter.WordWriter.Document, ByVal style As SoftArtisans.OfficeWriter.WordWriter.NamedStyle, ByVal insertAfterElement As SoftArtisans.OfficeWriter.WordWriter.Element) As SoftArtisans.OfficeWriter.WordWriter.Element
{signature}
{parameters}
{param:xhtml}A well\-formed fragment of an xhtml document.{param}
{param:doc}a WordWriter document object into which content will be inserted.{param}
{param:style}\(Optional\) a user\-specified WordWriter style that contains the font to use when inserting text.{param}
{param:insertAfterElement}The WordWriter element after which the contents of the xhtml will be inserted.{param}
{returns}The last Element inserted into the document.{returns}
{example}{code:csharp|title=C#}

//--- Create a new WordWriter document.
WordApplication wApp = new WordApplication();
Document doc = wApp.Create();

//--- Create the HTMLToWord object.
HTMLToWord h2w = new HTMLToWord();

//--- The XHTML to insert into the WordWriter document.
string xhtml = "<h1>Greetings</h1><p><b>Hello</b>, <i>world</i>!</p>";

//--- Create a style that uses a red Arial 11 point font.
NamedStyle myStyle = doc.Styles[NamedStyle.BuiltIn.Normal];
Font myFont = myStyle.Font;
myFont.Name = "Arial";
myFont.Size = 11;
myFont.Color = System.Drawing.Color.Red;
myStyle.Font = myFont;

//--- Insert the XHTML at the end of the WordWriter document.
Element lastInsertedElement = h2w.InsertHTML(xhtml, doc, myStyle, table);
{code}
{code:vb.net|title=vb.net}

'--- Create a new WordWriter document.
Dim wApp As New WordApplication()
Dim doc As Document = wApp.Create()

'--- Create the HTMLToWord object.
Dim h2w As New HTMLToWord()

'--- The XHTML to insert into the WordWriter document.
Dim xhtml As String = "<h1>Greetings</h1><p><b>Hello</b>, <i>world</i>!</p>"

'--- Insert the XHTML at the end of the WordWriter document.
Dim lastInsertedElement As Element = h2w.InsertHTML(xhtml, doc, null, doc)
{code}

{example}