Añadir PDF de sello de imagen a través de JavaScript via C++

Cree un sello de imagen con Aspose.PDF mediante las API JavaScript via C++

Cómo añadir sellos de imagen a un PDF con la biblioteca JavaScript via C++

Para añadir un sello de imagen al archivo PDF, utilizaremos la API Aspose.PDF, que es una API de manipulación de documentos rica en funciones, potente y fácil de usar para la plataforma javascript-cpp. Abra el administrador de paquetes NuGet, busque Aspose.pdf e instálelo. También puede usar el siguiente comando desde la consola de Package Manager.

Agregar sello de imagen al documento PDF JavaScript via C++


Necesita biblioteca Aspose.PDF para probar el código en su entorno.

  1. Cargue el PDF con una instancia de Document.
  2. Abra un documento PDF con el objeto Document.
  3. Cree un sello de imagen y defina sus propiedades.
  4. Agregar el sello a la página mediante el método AddStamp

Agregar sello de imagen al 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]);
    };