Remove Pages from PDF via JavaScript via C++

Delete pages from PDF document using Aspose.PDF for JavaScript via C++

How to Delete pages from PDF Using JavaScript via C++

Remove pages from PDF using the Aspose.PDF for JavaScript. To protect private information, you may need to delete pages or sections containing confidential data before sharing the document with others. Large PDF files can be cumbersome to share or store. Deleting pages helps reduce the file size, making it easier to transmit or archive. Also, removing pages streamline the document and deletes unnecessary repetition. A document may contain pages with errors or outdated information. Deleting these pages enhances the document’s overall quality. Removing pages can make it easier for users to navigate a PDF, ensuring they find the information they need quickly without scrolling through irrelevant content. When deleting pages from a PDF, it’s important to use a reliable PDF editor or software to ensure that the resulting document remains accurate and error-free. The Aspose.PDF for JavaScript library can remove pages from PDF in a few steps. If your PDF contains confidential or confidential information that you do not want to share or distribute, you may delete these specific pages to ensure the privacy and security of the remaining content. Sometimes you may need only certain pages or sections of a PDF document. In such cases, removing unnecessary pages allows you to extract and work with the corresponding content separately. If you delete unnecessary pages, you can significantly reduce the file size by simplifying document sharing or loading. In order to delete page from PDF file, we’ll use Aspose.PDF for JavaScript 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 JavaScript via C++ extract files from the ZIP archive.

Delete Page from PDF via JavaScript via C++


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

  1. Open the existing document.

  2. Delete a particular page.

  3. Save the output PDF using the Save method.

The provided JavaScript via C++ code snippet shows how to delete a particular page from a PDF document using the Aspose.PDF library. First, you should open an existing PDF document named ‘DeleteParticularPage.pdf’. Next, delete a particular page from the PDF document. Save the updated PDF document to the specified directory with the new file name ‘DeleteParticularPage_out.pdf’.

Remove Pages from PDF

This sample code shows how to delete pages from PDF - JavaScript via C++


    var ffileDeletePages = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        /*string, include number pages with interval: "7, 20, 22, 30-32, 33, 36-40, 46"*/
        const numPages = "1-3";
        /*array, array of number pages*/
        /*const numPages = [1,3];*/
        /*number, number page*/
        /*const numPages = 1;*/
        /*delete 1-3 pages a PDF-file and save the "ResultOptimize.pdf"*/
        const json = AsposePdfDeletePages(event.target.result, e.target.files[0].name, "ResultDeletePages.pdf", numPages);
        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]);
    };