通過C++提取 PDF 元數據

如何使用 C++ 庫編輯 PDF 元數據

如何使用 C++ 庫提取 PDF 元數據

為了從PDF檔中提取元數據,我們將使用[Aspose.PDF for C++](https://products.aspose.com/pdf/cpp)API,這是一個功能豐富,功能強大且易於使用的文檔操作API,適用於C++平臺。打開 [NuGet](https://www.nuget.org/packages/aspose.pdf.cpp) 包管理器,搜索“阿波斯.PDF.Cpp”並進行安裝。您也可以從程式包管理器主控台使用以下命令。

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

通過C++提取 PDF 元數據


您需要為 Aspose.PDF for C++才能在您的環境中嘗試代碼。

  1. 載入包含文件實例的 PDF。
  2. 使用 Document.Info 屬性獲取文件資訊。 1.訪問和顯示不同的 Document.Info 屬性。

<% metadata.code-block.text %>

提取 PDF 的元資料 - C++

<% metadata.code-block.subtitle %>

Input file:

File not added

Output format:

Output file:

    auto pdfDocument = MakeObject<Document>(_dataDir + u"SetFileInfo.pdf");
    auto docInfo = MakeObject<DocumentInfo>(pdfDocument);
    docInfo->set_Author(u"Aspose");
    docInfo->set_CreationDate(DateTime::get_Now());
    docInfo->set_Keywords (u"Aspose.Pdf, DOM, API");
    docInfo->set_ModDate (DateTime::get_Now());
    docInfo->set_Subject (u"PDF Information");
    docInfo->set_Title (u"Setting PDF Document Information");
    // Save output document
    pdfDocument->Save(_dataDir + u"SetFileInfo_out.pdf");