HTML JPG PDF XML DOCX
  Product Family
PDF

Remove Text from PDF in Node.js SDK

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

Get Started

How to delete Text from PDF via Node.js SDK

To delete text 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 Text using Node.js

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

  1. Load your Application Secret and Key from the JSON file or set credentials in another way
  2. Create an object to connect to the Cloud API
  3. Upload your document file
  4. Perform the removing the text using pdfApi.postDocumentTextReplace function
  5. Download the result if needed it
 

Remove Text from PDF using Node.js


    async function () {
        const pdfApi = new PdfApi(credentials.id, credentials.key);
        try {
            const fileBuffer = await fs.readFile(LOCAL_FILE_NAME);
            await pdfApi.uploadFile(STORAGE_FILENAME, fileBuffer);
            const textReplaceList =
            {
                textReplaces:
                    [
                        { oldValue: "text", newValue: "" },
                        { oldValue: "1", newValue: "" }
                    ]
            }
            const result = await pdfApi.postDocumentTextReplace(STORAGE_FILENAME, textReplaceList);
            console.log("Status:", result.body.status);
            const downloadRes = await pdfApi.downloadFile(STORAGE_FILENAME);
            await fs.writeFile(RESULT_FILENAME, downloadRes.body);
        }
        catch (error) {
            console.error(error.message);
        }
    }
 

With our Node.js tool 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 replace text in PDF files online and test the functionality.