通過JavaScript via C++提取 PDF 元數據

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

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

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

通過JavaScript via C++提取 PDF 元數據


您需要 [Aspose.PDF 庫](https://releases.aspose.com/pdf) 來嘗試環境中的代碼。

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

<% metadata.code-block.text %>

提取 PDF 的元資料 - JavaScript via C++

<% metadata.code-block.subtitle %>

Input file:

File not added

Output format:

Output file:


    var ffilePdfGetInfo = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        /*Get info (metadata) from PDF file.*/
        const json = AsposePdfGetInfo(event.target.result, e.target.files[0].name);
        /* JSON
        Title:    json.title
        Creator:  json.creator
        Author:   json.author 
        Subject:  json.subject
        Keywords: json.keywords
        Creation Date: json.creation
        Modify Date:   json.mod
        */
        if (json.errorCode == 0) document.getElementById('output').textContent = "JSON:\n" + JSON.stringify(json, null, 4);
        else document.getElementById('output').textContent = json.errorText;
        };
        file_reader.readAsArrayBuffer(e.target.files[0]);
    };