2017-03-26 97 views
0

我們如何修改PDF文件中的所有屬性?
我見過的document properties example並結束了與此:使用GemBox.Document編輯PDF文件屬性

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沒有ProducerCreator枚舉。我錯過了什麼嗎?

回答

1

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"; 

我希望這有助於。

+0

感謝馬里奧,內置的「應用程序」和自定義「生產者」屬性工作!也謝謝你的日期相關的屬性,它會派上用場。 – Kipper