如何在C#中使用Xceed删除Word文件的相关人员作者和修改者属性

问题描述

我正在使用 Xceed 库来创建一个 word 文件。现在我想删除word文档的相关人员(作者和修改者)属性。

这是我的代码:

using Xceed.Words.NET;
using Xceed.Document.NET;
using Image = Xceed.Document.NET.Image;
using Paragraph = Xceed.Document.NET.Paragraph;
using Formatting = Xceed.Document.NET.Formatting;
using Font = Xceed.Document.NET.Font;

我怎样才能做到这一点?

解决方法

回答我自己的问题,这可以通过添加 AddCoreProperty 来完成,如下所示:

// Load your Document
var doc = DocX.Load(@"your-docx-file-path");
// Access Metadata properties
var props = doc.CoreProperties;
// Update Metadata
doc.AddCoreProperty("cp:lastModifiedBy","");
doc.AddCoreProperty("dc:creator","");
doc.Save();

Set docx properties using library .docx

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...