【问题标题】:PDFsharp - C# - KeyValuePair - PowerShell conversionPDFsharp - C# - KeyValuePair - PowerShell 转换
【发布时间】:2020-08-25 02:56:58
【问题描述】:

查看 C# 代码示例 (Here)。我正在尝试研究如何将所需的 KeyPair 语法转换为 PowerShell。我有一个工作 PowerShell 代码的示例,它将使用 PDFsharp 程序集创建一个文件,我想修改该脚本以修改 PDF 文件的自定义属性。

【问题讨论】:

  • 试试New-Object 'System.Collections.Generic.KeyValuePair[Type1,Type2]'。 Type1 应该是string,Type2 类似于PDFItemPDFSharp.Item.PDFItem

标签: c# powershell pdf pdfsharp


【解决方案1】:

您实际上不需要手动创建KeyValuePair 对象,PdfDocument 上的Info 属性有一个Add() 方法,该方法将字符串作为键,将PdfItem 对象作为值:

$propertyKey = "/MyKey"
$propertyValue = "MyValue"
$document.Info.Add($propertyKey, [PdfSharp.Pdf.PdfString]::new($propertyValue))

【讨论】:

  • 非常感谢。我使用 $document.Info.Elements.Add([KeyValuePair[string,PdfItem]]::new("/MyKey",[PdfString]::new("MyValue")))
猜你喜欢
  • 2019-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-05
  • 2012-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多