文件元數據解決方案

使用免費的跨平臺應用程式和 API 查看和編輯 PDF 文件的內置和自定義屬性

如何使用「.PDF庫」設置 PDF 元數據

要從 PDF 檔設置元數據,我們將使用 [Aspose.PDF](https://products.aspose.com/pdf) API,這是一個功能豐富、功能強大且易於使用的文檔操作 API。打開 [NuGet](https://www.nuget.org/packages/aspose.pdf) 包管理器,搜索“aspose.PDF然後安裝。您也可以從程式包管理器主控台使用以下命令。Aspose.PDF允許您為 PDF 設置特定於文件的資訊,如作者、創建日期、主題和標題等資訊。

設置 PDF 元數據的步驟


您需要 Aspose.PDF 庫 在您的環境中試用代碼。

  1. 使用文檔實例加載 PDF。
  2. 設置屬性值。
  3. 使用 Document 類的 Save 方法保存更新的文檔。

通過 C 設定 PDF 檔案資訊#

此示例代碼顯示如何設置 PDF 的元數據信息

    // Open document
    Document pdfDocument = new Document(dataDir + "SetFileInfo.pdf");

    // Specify document information
    DocumentInfo docInfo = new DocumentInfo(pdfDocument);

    docInfo.Author = "Aspose";
    docInfo.CreationDate = DateTime.Now;
    docInfo.Keywords = "Aspose.Pdf, DOM, API";
    docInfo.ModDate = DateTime.Now;
    docInfo.Subject = "PDF Information";
    docInfo.Title = "Setting PDF Document Information";

    dataDir = dataDir + "SetFileInfo_out.pdf";
    // Save output document
    pdfDocument.Save(dataDir);