Example: Convert to HTML |
[Top] [Chapter] [Previous] [Next] |
This C# example loops through the text and create HTML which consist only of <p> and <a> tags. (You can of course use the internal HTML converter)
IWPMemo Memo = wpdllInt1.Memo; StringBuilder HtmlText = new StringBuilder(); IWPTextCursor TextCursor; IWPTextObj Obj; IWPParInterface par = Memo.CurrPar; bool parstart = true;
Memo = wpdllInt1.Memo; TextCursor = Memo.TextCursor; Obj = Memo.CurrObj;
TextCursor.GotoStart(); while(true) { if (parstart) { HtmlText.Append("<p>"); parstart = false; }
if (TextCursor.CPObjPtr!=0) { if (Obj.ObjType==TextObjTypes.wpobjHyperlink) { HtmlText.Append("<a href=\""); HtmlText.Append(Obj.Command); HtmlText.Append("\">"); HtmlText.Append(Obj.EmbeddedText); HtmlText.Append("</a>"); Obj.MoveCursor(4); // Before end tag - we skip later } } else if (TextCursor.CPPosInPar>=par.CharCount) { HtmlText.Append("</p>\r\n"); parstart = true; } else HtmlText.Append( (char)par.GetChar(TextCursor.CPPosInPar), 1 ); if (!TextCursor.CPMoveNext()) break; }
MessageBox.Show(HtmlText.ToString(),""); |