使用“通過JavaScript via C++在 PDF 中添加數字簽名

本機和高性能 PDF 文件數位簽名生成和驗證使用伺服器端 Aspose.PDF用於 .NET API,而無需使用包括 Adobe PDF 在內的任何軟體 - JavaScript via C++。

如何使用 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. 載入所有具有完整路徑的PDF檔。 設置文字的樣式,如字體,字體大小,顏色等。 保存PDF檔,您將獲得插入簽名的文件。
  3. 要驗證簽名的有效性,請使用簽名()方法。

使用 - JavaScript via C++將電子簽名添加到 PDF 檔。

<% signature.code-block.subtitle %>

Input file:

File not added

Certificate file:

File not added

Output format:

Output file:


    var ffileSignPKCS7 = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        let pswSign = document.getElementById("passwordSign").value;
        /*sign a PDF-file and save the "ResultSignPKCS7.pdf"*/
        const json = AsposePdfSignPKCS7(event.target.result, e.target.files[0].name, 1, fileSign, pswSign, 200, 200, 200, 100, "TEST", "test@test.com", "EU", 1, signatureAppearance,"ResultSignPKCS7.pdf");
        if (json.errorCode == 0) document.getElementById('output').textContent = json.fileNameResult;
        else document.getElementById('output').textContent = json.errorText;
        /*make a link to download the result file*/
        DownloadFile(json.fileNameResult, "application/pdf");
        };
        file_reader.readAsArrayBuffer(e.target.files[0]);
    };