HTML JPG PDF XML DOCX
  Product Family
PDF

Remove Image from PDF in Node.js SDK

Delete a Images from a PDF Document using Cloud Node.js SDK

Get Started

How to delete Images from PDF via Node.js SDK

To delete Images from PDF, we’ll use Aspose.PDF Cloud Node.js SDK. This Cloud SDK assists Node.js programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Node.js programming language via Aspose.PDF REST API. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Node.js SDK.

Package Manager Console Command


     
    npm install asposepdfcloud --save
     
     

Steps to delete Images using Node.js

Aspose.PDF Cloud developers can easily load & delete Images from PDF in just a few lines of code.

  1. Get images from specific page.
  2. Choose desired image by image id.
  3. Load your Application Secret and Key from the JSON file or set credentials in another way.
  4. Retrieves the desired image from the uploaded PDF file.
  5. Deletes the retrieved image from the PDF file in the cloud storage.
  6. Download the result if needed it
 

Remove Images from PDF using Node.js


    import credentials from "./credentials.json"  with { type: "json" };
    import fs from 'node:fs/promises';
    import { PdfApi } from "asposepdfcloud";

    async function delete() {
        const localPdfFile = "C:\\Samples\\Sample.pdf";
        const storagePdfFile = "Sample.pdf";

        const pdfApi = new PdfApi(credentials.id, credentials.key);
        try {
            let fileData = await fs.readFile(localPdfFile);
            let uploadResult = await pdfApi.uploadFile(storagePdfFile, fileData);
            console.log(uploadResult.response.text);
        }
        catch (error) {
            console.error(error.message);
        }

        try {
            const result = await pdfApi.getImages(storagePdfFile, 1, null, null);
            const imageId = result.body.images.list[0].id;
            const response = await pdfApi.deleteImage(storagePdfFile, imageId);
            console.log(response.body.status);
        }
        catch (error) {
            console.error(error.message);
        }
    }
 

Work with Images in PDF

Images often contribute significantly to the size of a PDF. Removing them can make the document smaller and easier to share, especially in email or online uploads. Images may contain sensitive information, such as personal photos or proprietary visuals. Removing them ensures the document respects privacy or confidentiality requirements. Removing images from a PDF is a strategic step in ensuring the document is optimized for specific use cases, whether it’s for storage, sharing, or readability. Delete the Images from PDF documents with Aspose.PDF Cloud Node.js SDK.

With our Node.js library you can:

  • Add PDF document’s header & footer in text or image format.
  • Add tables & stamps (text or image) to PDF documents.
  • Append multiple PDF documents to an existing file.
  • Work with PDF attachments, annotations, & form fields.
  • Apply encryption or decryption to PDF documents & set a password.
  • Delete all stamps & tables from a page or entire PDF document.
  • Delete a specific stamp or table from the PDF document by its ID.
  • Replace single or multiple instances of text on a PDF page or from the entire document.
  • Extensive support for converting PDF documents to various other file formats.
  • Extract various elements of PDF files & make PDF documents optimized.
  • You can try out our free App to change image dimensions in PDF files online and test the functionality.