public static void SaveHtmlFile(string fileName, bool saveAttachFile, DomDocument document) { if (fileName == null) { throw new ArgumentNullException("fileName"); } if (document == null) { throw new ArgumentNullException("document"); } WriterHtmlDocumentWriter htmlWriter = new WriterHtmlDocumentWriter(); htmlWriter.Documents.Add(document); htmlWriter.IncludeSelectionOndly = false; htmlWriter.ViewStyle = WriterHtmlViewStyle.Normal; htmlWriter.Options.Indent = true; htmlWriter.Options.UseClassAttribute = false; htmlWriter.Refresh(); string attachFilePath = null; if (htmlWriter.AttachFiles != null && htmlWriter.AttachFiles.Count > 0) { // 存在附属文件,则创建附属文件目录 attachFilePath = Path.GetDirectoryName(fileName); string name = Path.GetFileNameWithoutExtension(fileName) + ".files"; attachFilePath = Path.Combine(attachFilePath, name); if (Directory.Exists(attachFilePath) == false) { Directory.CreateDirectory(attachFilePath); } }//if htmlWriter.Save(fileName, attachFilePath); }
public override void WriteHTML(WriterHtmlDocumentWriter writer) { if (intListStyle == ParagraphListStyle.BulletedList) { writer.WriteStartElement("ul"); } else { writer.WriteStartElement("ol"); } DomElementList list = WriterUtils.MergeElements(this.Elements, false); if (list != null && list.Count > 0) { foreach (DomElement element in list) { if (writer.IncludeSelectionOndly == false || element.HasSelection) { element.WriteHTML(writer); } } } writer.WriteEndElement(); }
protected virtual void WriteContentHTML(WriterHtmlDocumentWriter writer) { DomElementList list = WriterUtils.MergeElements( this.Elements, true); if (list != null && list.Count > 0) { foreach (DomElement element in list) { if (writer.IncludeSelectionOndly == false || element.HasSelection) { element.WriteHTML(writer); } } } }
public override void WriteHTML(WriterHtmlDocumentWriter writer) { WriteContentHTML(writer); }
public override void WriteHTML(WriterHtmlDocumentWriter writer) { writer.WriteElementString("br", ""); }
/// <summary> /// 输出HTML代码 /// </summary> /// <param name="writer">XML书写器</param> public virtual void WriteHTML(WriterHtmlDocumentWriter writer) { }