Remove Images from PDF document via JavaScript

Delete images from PDF document using Aspose.PDF for Node.js via C++ Library

Remove Images from PDF Document Using JavaScript Library

In order to remove Image from PDF file, we’ll use Aspose.PDF for Node.js via C++ is a easy and secure toolkit used to work with PDF directly in the web browser. To install and use Aspose.PDF for Node.js via C++ extract files from the ZIP archive.

Delete Images from PDF via JavaScript


You need Aspose.PDF for Node.js via C++ to try the code in your environment.

  1. Import the Aspose.PDF module.
  2. Define a constant for output file.
  3. Call the AsposePdf function.
  4. Call the AspoAsposePdfDeleteImages method.
  5. Use the console.log method to print the result.

Delete Images from Existing PDF File - JavaScript

This sample code shows how to remove Images from PDF - JavaScript

const AsposePdf = require('../AsposePDFforNode.js');
const pdf_file = '../ReadMe.pdf';
AsposePdf().then(AsposePdfModule => {
    /*Delete images a PDF-file and save the "ResultPdfDeleteImages.pdf"*/
    const json = AsposePdfModule.AsposePdfDeleteImages(pdf_file, "./ResultPdfDeleteImages.pdf");
    console.log("AsposePdfDeleteImages => %O", json.errorCode == 0 ? json.fileNameResult : json.errorText);
});