代码之家  ›  专栏  ›  技术社区  ›  i486

XPS文档中的注释

  •  4
  • i486  · 技术社区  · 6 年前

    我正在尝试在XPS文档中添加评论。是否可以使用.NET API并将其读回?我需要添加嵌入在xps文件中的隐藏文本。

    1 回复  |  直到 6 年前
        1
  •  5
  •   Steven Rands    6 年前
    XpsDocument CoreDocumentProperties property

    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
            }
        }
    }
    

    using (var document = new XpsDocument(XpsFilePath, FileAccess.Read))
    {
        PackageProperties properties = document.CoreDocumentProperties;
        System.Console.WriteLine(properties.Title);
        // etc...
    }
    

    Properties for XPS document

    推荐文章