通過JavaScript via C++添加圖像圖章 PDF

使用 JavaScript via C++ API 建立.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”並安裝。您也可以從程式包管理器主控台使用以下命令。

將影像圖章加入到 PDF 文件 JavaScript via C++


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

  1. 載入包含文件實例的 PDF。
  2. 使用文件對象打開 PDF 文件。
  3. 建立影像戳並定義其屬性。
  4. 使用添加時間戳方法將圖章添加到頁面

將影像圖章加入到 PDF - JavaScript via C++。


    var ffileStamp = function (e) {
        const file_reader = new FileReader();
        /*set the stamp filename*/
        fileStamp = e.target.files[0].name;
        file_reader.onload = (event) => {
        /*prepare(save) the stamp file from BLOB*/
        AsposePdfPrepare(event.target.result, fileStamp);
        };
        file_reader.readAsArrayBuffer(e.target.files[0]);
    };

    var ffileAddStamp = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        /*insert the stamp file to a PDF-file and save the "ResultStamp.pdf"*/
        const json = AsposePdfAddStamp(event.target.result, e.target.files[0].name, fileStamp, 0, 5, 5, 40, 40, Module.Rotation.on270, 0.5, "ResultStamp.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]);
    };