使用 GemBox.Document 编辑 PDF 文件属性
Edit file properties in PDF with GemBox.Document
如何修改PDF文件中的所有属性?
我看过 document properties example,结果是这样的:
DocumentModel document = DocumentModel.Load("Input.docx");
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Application] = "My Application";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Title] = "My Title";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Author] = "My Author";
// Etc ...
document.Save("Output.pdf");
但是缺少一些属性,例如 BuiltInDocumentProperty 中没有 Producer
和 Creator
枚举。我错过了什么吗?
BuiltInDocumentProperty
枚举基于 Word 文档,但请尝试以下示例:
// The "BuiltInDocumentProperty.Application" is the PDF's "Creator" property.
// If you're experiencing an issue with it, try downloading the latest bug fix version:
// https://www.gemboxsoftware.com/document/downloads/BugFixes.htm
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Application] = "My Application";
// The PDF's "Producer" property is missing, but you can use the following:
document.DocumentProperties.Custom.Add("Producer", "My Producer");
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Title] = "My Title";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Author] = "My Author";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Subject] = "My Subject";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Keywords] = "My Keywords";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.DateContentCreated] =
new DateTime(2000, 1, 1).ToString("s") + "Z";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.DateLastSaved] =
new DateTime(2000, 1, 1).ToString("s") + "Z";
希望对您有所帮助。
如何修改PDF文件中的所有属性?
我看过 document properties example,结果是这样的:
DocumentModel document = DocumentModel.Load("Input.docx");
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Application] = "My Application";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Title] = "My Title";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Author] = "My Author";
// Etc ...
document.Save("Output.pdf");
但是缺少一些属性,例如 BuiltInDocumentProperty 中没有 Producer
和 Creator
枚举。我错过了什么吗?
BuiltInDocumentProperty
枚举基于 Word 文档,但请尝试以下示例:
// The "BuiltInDocumentProperty.Application" is the PDF's "Creator" property.
// If you're experiencing an issue with it, try downloading the latest bug fix version:
// https://www.gemboxsoftware.com/document/downloads/BugFixes.htm
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Application] = "My Application";
// The PDF's "Producer" property is missing, but you can use the following:
document.DocumentProperties.Custom.Add("Producer", "My Producer");
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Title] = "My Title";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Author] = "My Author";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Subject] = "My Subject";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.Keywords] = "My Keywords";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.DateContentCreated] =
new DateTime(2000, 1, 1).ToString("s") + "Z";
document.DocumentProperties.BuiltIn[BuiltInDocumentProperty.DateLastSaved] =
new DateTime(2000, 1, 1).ToString("s") + "Z";
希望对您有所帮助。