public void AcceptAllRevisions() { //ExStart //ExFor:Document.AcceptAllRevisions //ExId:AcceptAllRevisions //ExSummary:Shows how to accept all tracking changes in the document. Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "Document.doc"); doc.AcceptAllRevisions(); //ExEnd }
public void AcceptAllRevisions() { //ExStart //ExFor:Document.AcceptAllRevisions //ExId:AcceptAllRevisions //ExSummary:Shows how to accept all tracking changes in the document. Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.doc"); doc.AcceptAllRevisions(); //ExEnd }
public void AcceptAllRevisions() { //ExStart //ExFor:Document.AcceptAllRevisions //ExSummary:Shows how to accept all tracking changes in the document. Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.doc"); // Start tracking and make some revisions. doc.StartTrackRevisions("Author"); doc.FirstSection.Body.AppendParagraph("Hello world!"); // Revisions will now show up as normal text in the output document. doc.AcceptAllRevisions(); doc.Save(MyDir + "Document.AcceptedRevisions.doc"); //ExEnd }
/// <summary> /// doc清洁方法 /// </summary> /// <param name="srcBytes">doc源二进制数据</param> /// <param name="extension"></param> /// <returns></returns> public static byte[] CleanDoc(byte[] srcBytes, string extension) { // 参数验证 if (srcBytes == null) { throw new InvalidDataException(); } if (string.IsNullOrEmpty(extension)) { throw new InvalidDataException(); } byte[] result = null; Stream docStream = new System.IO.MemoryStream(srcBytes); Aspose.Words.Document doc = new Aspose.Words.Document(docStream); // 接受全部修订 doc.AcceptAllRevisions(); //StyleCollection styleCollection= //清除批注 NodeCollection nodeCollection = doc.GetChildNodes(NodeType.Comment, true); foreach (Node comment in nodeCollection) { nodeCollection.Remove(comment); } //二进制另存 using (MemoryStream ms = new MemoryStream()) { if (extension == ".docx" || extension == "docx") { doc.Save(ms, SaveFormat.Docx); result = ms.ToArray(); } if (extension == ".doc" || extension == "doc") { doc.Save(ms, SaveFormat.Doc); result = ms.ToArray(); } } return(result); }
/// <summary> /// WORD转换成图片 /// </summary> /// <param name="fileUrl">源文件路径</param> /// <param name="resolution">图片分辨率</param> /// <param name="imgQuality">图片质量</param> /// <returns>返回值格式:图片存放目录|页数</returns> private int ConvertWord2Image(string srcFilePath, string destFileDir, string destFileName, int startPageNum, int endPageNum, ImageFormat imgFormat, int imgResolution, int imgQuality) { // validate path ValidateHelper.Begin().NotNullAndEmpty(srcFilePath).FileExist(srcFilePath).NotNullAndEmpty(destFileDir) .NotNull(imgFormat).InRange(imgResolution, 1, 512).InRange(imgQuality, 1, 100); string imageExtention = "." + imgFormat.ToString(); if (imgFormat == ImageFormat.Jpeg) { imageExtention = ".jpg"; } if (!string.IsNullOrEmpty(destFileName)) { destFileName = destFileName + "_"; } if (!Directory.Exists(destFileDir)) { Directory.CreateDirectory(destFileDir); } // open word file Aspose.Words.Document wordFile = new Aspose.Words.Document(srcFilePath); if (wordFile.HasRevisions) { wordFile.AcceptAllRevisions(); } if (startPageNum <= 0) { startPageNum = 1; } if (endPageNum > wordFile.PageCount || endPageNum <= 0) { endPageNum = wordFile.PageCount; } if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = tempPageNum; } ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imgFormat)); imageSaveOptions.Resolution = (float)imgResolution; imageSaveOptions.JpegQuality = imgQuality; // start to convert each page try { for (int i = startPageNum - 1; i < endPageNum; i++) { imageSaveOptions.PageIndex = i; wordFile.Save(Path.Combine(destFileDir, destFileName + i.ToString() + imageExtention), imageSaveOptions); } } catch (Exception ex) { throw ex; } return(endPageNum - startPageNum + 1); }