您可以使用类及其属性将元数据添加到XPS文档文件.XpsDocumentCoreDocumentProperties
我不确定这是否能满足您的要求,但这是如何做到的.
using System.IO;
using System.IO.Packaging;
using System.Windows.Xps.Packaging;
namespace StackOverflow
{
class Program
{
static void Main(string[] args)
{
const string XpsFilePath = @" ... path to XPS file ... ";
using (var document = new XpsDocument(XpsFilePath, FileAccess.ReadWrite))
{
PackageProperties properties = document.CoreDocumentProperties;
properties.Title = "Some title";
properties.Subject = "Some subject line";
properties.Keywords = "stackoverflow xps";
properties.Category = "Some category";
properties.Description = "Some kind of document";
properties.Creator = "me";
properties.LastModifiedBy = "me again";
properties.Revision = "Rev A";
properties.Version = "v1";
}
// XpsDocument is from System.Windows.Xps.Packaging, in ReachFramework assembly
// PackageProperties is from System.IO.Packaging, in WindowsBase assembly
}
}
}
Run Code Online (Sandbox Code Playgroud)
您可以通过创建XpsDocument具有读访问权限的新功能,通过代码访问此信息.
using (var document = new XpsDocument(XpsFilePath, FileAccess.Read))
{
PackageProperties properties = document.CoreDocumentProperties;
System.Console.WriteLine(properties.Title);
// etc...
}
Run Code Online (Sandbox Code Playgroud)
您可以通过右键单击文件,选择" 属性",然后显示" 详细信息"选项卡,在Windows中查看XPS文档的元数据:

元数据不是严格隐藏的,因为您可以使用上述技术在Windows中看到它或通过代码访问它.但是,它不会显示在XPS文档的实际页面上,因此在查看或打印时通常不会显示.
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |