当前位置: 首页>>代码示例>>C#>>正文


C# OpenXmlPowerTools.WmlDocument类代码示例

本文整理汇总了C#中OpenXmlPowerTools.WmlDocument的典型用法代码示例。如果您正苦于以下问题:C# WmlDocument类的具体用法?C# WmlDocument怎么用?C# WmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WmlDocument类属于OpenXmlPowerTools命名空间,在下文中一共展示了WmlDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddToc

 public static WmlDocument AddToc(WmlDocument document, string xPath, string switches, string title, int? rightTabPos)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(document))
     {
         using (WordprocessingDocument doc = streamDoc.GetWordprocessingDocument())
         {
             AddToc(doc, xPath, switches, title, rightTabPos);
         }
         return streamDoc.GetModifiedWmlDocument();
     }
 }
开发者ID:bbqchickenrobot,项目名称:OpenXmlPowerTools,代码行数:11,代码来源:ReferenceAdder.cs

示例2: GetAllComments

 public static object GetAllComments(WmlDocument doc, CommentFormat format)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
     {
         IEnumerable<XElement> comments = null;
         WordprocessingCommentsPart commentsPart = document.MainDocumentPart.WordprocessingCommentsPart;
         if (commentsPart != null)
         {
             XDocument commentsPartDocument = commentsPart.GetXDocument();
             comments = commentsPartDocument.Element(W.comments).Elements(W.comment);
         }
         if (comments != null)
         {
             XDocument commentsDocument =
                 new XDocument(
                     new XElement(W.comments,
                         new XAttribute(XNamespace.Xmlns + "w", W.w),
                         comments
                     )
                 );
             switch (format)
             {
                 case CommentFormat.PlainText:
                     return commentsDocument.ToString();
                 case CommentFormat.Xml:
                     return commentsDocument;
                 case CommentFormat.Docx:
                     return CreateCommentsDocument(comments);
             }
         }
         return null;
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:34,代码来源:CommentAccessor.cs

示例3: mergeDocx

        static void mergeDocx(string paramOutputFile, List<FileStream> paramDocumentstreams)
        {
            var sources = new List<Source>();

            try
            {

                foreach (var stream in paramDocumentstreams)
                {
                    var tempms = new MemoryStream();
                    if (0 != stream.Length)
                    {
                        stream.CopyTo(tempms);
                        WmlDocument doc = new WmlDocument(stream.Length.ToString(), tempms);
                        sources.Add(new Source(doc, true));
                    }
                    tempms.Close();

                }

                Console.WriteLine("Merging documents...");
                var mergedDoc = DocumentBuilder.BuildDocument(sources);
                mergedDoc.SaveAs(paramOutputFile);

            }
            catch (Exception e)
            {
                Console.WriteLine("An Error ocurred while merging, please check the log: ");
                Console.WriteLine(e.ToString());
            }
        }
开发者ID:Softcom,项目名称:docxmerger,代码行数:31,代码来源:Program.cs

示例4: Source

 public Source(WmlDocument source, int start, int count, bool keepSections)
 {
     WmlDocument = source;
     Start = start;
     Count = count;
     KeepSections = keepSections;
 }
开发者ID:mvlasenko,项目名称:TridionDesktopTools,代码行数:7,代码来源:DocumentBuilder.cs

示例5: Source

 public Source(WmlDocument source, int start, int count, string insertId)
 {
     WmlDocument = source;
     Start = start;
     Count = count;
     KeepSections = false;
     InsertId = insertId;
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:8,代码来源:DocumentBuilder.cs

示例6: Source

 public Source(string fileName, bool keepSections)
 {
     WmlDocument = new WmlDocument(fileName);
     Start = 0;
     Count = Int32.MaxValue;
     KeepSections = keepSections;
     InsertId = null;
 }
开发者ID:BogdanDamianC,项目名称:Open-Xml-PowerTools,代码行数:8,代码来源:DocumentBuilder.cs

示例7: Source

 public Source(string fileName, string insertId)
 {
     WmlDocument = new WmlDocument(fileName);
     Start = 0;
     Count = Int32.MaxValue;
     KeepSections = false;
     InsertId = insertId;
 }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:8,代码来源:DocumentBuilder.cs

示例8: Insert

        /// <summary>
        /// Inserts Xml markup representing format attributes inside a specific paragraph or paragraph run
        /// </summary>
        /// <param name="document">Document to insert formatting Xml tags</param>
        /// <param name="xpathInsertionPoint">Paragraph or paragraph run to set format</param>
        /// <param name="content">Formatting tags</param>
        public static OpenXmlPowerToolsDocument Insert(WmlDocument doc, string xpathInsertionPoint, string content)
        {
            using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
            {
                using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
                {
                    XDocument xDocument = document.MainDocumentPart.GetXDocument();
                    XmlDocument xmlMainDocument = new XmlDocument();
                    xmlMainDocument.Load(xDocument.CreateReader());

                    XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable());
                    namespaceManager.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");

                    XmlNodeList insertionPoints = xmlMainDocument.SelectNodes(xpathInsertionPoint, namespaceManager);

                    if (insertionPoints.Count == 0)
                        throw new ArgumentException("The xpath query did not return a valid location.");

                    foreach (XmlNode insertionPoint in insertionPoints)
                    {
                        XmlNode propertiesElement = insertionPoint.SelectSingleNode(@"w:pPr|w:rPr", namespaceManager);
                        if (insertionPoint.Name == "w:p")
                        {
                            // Checks if the rPr or pPr element exists
                            if (propertiesElement == null)
                            {
                                propertiesElement = xmlMainDocument.CreateElement("w", "pPr", namespaceManager.LookupNamespace("w"));
                                insertionPoint.PrependChild(propertiesElement);
                            }
                        }
                        else if (insertionPoint.Name == "w:r")
                        {
                            // Checks if the rPr or pPr element exists
                            if (propertiesElement == null)
                            {
                                propertiesElement = xmlMainDocument.CreateElement("w", "rPr", namespaceManager.LookupNamespace("w"));
                                insertionPoint.PrependChild(propertiesElement);
                            }
                        }

                        if (propertiesElement != null)
                        {
                            propertiesElement.InnerXml += content;
                        }
                        else
                        {
                            throw new ArgumentException("Specified xpath query result is not a valid location to place a formatting markup");
                        }

                    }
                    XDocument xNewDocument = new XDocument();
                    using (XmlWriter xWriter = xNewDocument.CreateWriter())
                        xmlMainDocument.WriteTo(xWriter);
                    document.MainDocumentPart.PutXDocument(xNewDocument);
                }
                return streamDoc.GetModifiedDocument();
            }
        }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:64,代码来源:ContentFormatAccessor.cs

示例9: PtWordprocessingCommentsPart

 public PtWordprocessingCommentsPart(WmlDocument wmlDocument, Uri uri, XName name, params object[] values)
     : base(name, values)
 {
     ParentWmlDocument = wmlDocument;
     this.Add(
         new XAttribute(PtOpenXml.Uri, uri),
         new XAttribute(XNamespace.Xmlns + "pt", PtOpenXml.pt)
     );
 }
开发者ID:BogdanDamianC,项目名称:Open-Xml-PowerTools,代码行数:9,代码来源:WmlDocument.cs

示例10: RA001_RevisionAccepter

        public void RA001_RevisionAccepter(string name)
        {
            FileInfo sourceDocx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name));

            WmlDocument notAccepted = new WmlDocument(sourceDocx.FullName);
            WmlDocument afterAccepting = RevisionAccepter.AcceptRevisions(notAccepted);
            var processedDestDocx = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceDocx.Name.Replace(".docx", "-processed-by-RevisionAccepter.docx")));
            afterAccepting.SaveAs(processedDestDocx.FullName);
        }
开发者ID:BogdanDamianC,项目名称:Open-Xml-PowerTools,代码行数:9,代码来源:RevisionAccepterTests.cs

示例11: GetBackgroundColor

 public static string GetBackgroundColor(WmlDocument doc)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
     {
         XDocument mainDocument = document.MainDocumentPart.GetXDocument();
         XElement backgroundElement = mainDocument.Descendants(W.background).FirstOrDefault();
         return (backgroundElement == null) ? string.Empty : backgroundElement.Attribute(W.color).Value;
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:10,代码来源:BackgroundAccessor.cs

示例12: ConvertToHtml

 public static XElement ConvertToHtml(WmlDocument doc, HtmlConverterSettings htmlConverterSettings, Func<ImageInfo, XElement> imageHandler)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     {
         using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
         {
             return ConvertToHtml(document, htmlConverterSettings, imageHandler);
         }
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:10,代码来源:HtmlConverter.cs

示例13: RetrieveListItem

 public static string RetrieveListItem(WmlDocument document,
     XElement paragraph, string bulletReplacementString)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(document))
     {
         using (WordprocessingDocument wdoc = streamDoc.GetWordprocessingDocument())
         {
             return RetrieveListItem(wdoc, paragraph, bulletReplacementString);
         }
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:11,代码来源:ListItemRetriever.cs

示例14: GetFooter

 /// <summary>
 /// Get the specified footer from the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 /// <returns>the XDocument containing the footer</returns>
 public static XDocument GetFooter(WmlDocument doc, FooterType type, int sectionIndex)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
     {
         OpenXmlPart footer = GetFooterPart(document, type, sectionIndex);
         if (footer != null)
             return footer.GetXDocument();
         return null;
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:16,代码来源:FooterAccessor.cs

示例15: AssembleFormatting

 public static WmlDocument AssembleFormatting(WmlDocument document, FormattingAssemblerSettings settings)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(document))
     {
         using (WordprocessingDocument doc = streamDoc.GetWordprocessingDocument())
         {
             AssembleFormatting(doc, settings);
         }
         return streamDoc.GetModifiedWmlDocument();
     }
 }
开发者ID:bbqchickenrobot,项目名称:OpenXmlPowerTools,代码行数:11,代码来源:FormattingAssembler.cs


注:本文中的OpenXmlPowerTools.WmlDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。