简体   繁体   English

PDFsharp - C# - KeyValuePair - PowerShell 转换

[英]PDFsharp - C# - KeyValuePair - PowerShell conversion

Looking at the sample of C# code ( Here ).查看 C# 代码示例(此处)。 I'm trying to work out how to convert the required KeyPair syntax into PowerShell.我正在尝试研究如何将所需的 KeyPair 语法转换为 PowerShell。 I have an example of working PowerShell code, which will use the PDFsharp assembly to create a file, I'd like to modify that script to also modify a Custom Property of the PDF file.我有一个工作 PowerShell 代码示例,它将使用 PDFsharp 程序集创建一个文件,我想修改该脚本以修改 PDF 文件的自定义属性。

You don't actually need to create the KeyValuePair object manually, the Info property on PdfDocument has an Add() method that takes a string as the key and a PdfItem object as the value:您实际上并不需要手动创建KeyValuePair对象, PdfDocument上的Info属性有一个Add()方法,该方法以字符串为键,以PdfItem对象为值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM