Split PDF via JavaScript via C++

Split PDF, HTML, TXT files. Use Aspose.PDF for JavaScript via C++ to modify PDF documents programmatically

Split Files Using Aspose.PDF for JavaScript via C++

If you only need certain pages from a large PDF document, splitting a file allows you to extract these specific pages as a separate document. Splitting PDF into smaller files can help you organize and manage content more efficiently. By splitting PDF into small files, you can reduce file size and make it more accessible. In order to encrypt 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.

Split documents via JavaScript via C++


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

  1. Load the PDF with an instance of Document.
  2. Create a new Document class object to split PDF pages.
  3. Add current page to the document.
  4. Save current page as a separate PDF

How to split PDF using JavaScript via C++

With the Aspose.PDF library, you can split large PDF documents. Splitting a PDF document is a common use case when working with PDF documents. It helps reduce the size of a PDF file by breaking large documents into smaller files to send via email.

Split PDF - JavaScript via C++

This sample code shows how to split PDF file - JavaScript via C++


    var ffileSplit = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        /*set number a page to split*/
        const pageToSplit = 1;
        /*split a PDF-file and save the "ResultSplit1.pdf", "ResultSplit2.pdf"*/
        const json = AsposePdfSplit2Files(event.target.result, e.target.files[0].name, pageToSplit, "ResultSplit1.pdf", "ResultSplit2.pdf");
        if (json.errorCode == 0) document.getElementById('output').textContent = e.target.files[0].name + " split: " + json.fileNameResult1 + ", " + json.fileNameResult2;
        else document.getElementById('output').textContent = json.errorText;
        /*make a link to download the first result file*/
        DownloadFile(json.fileNameResult1, "application/pdf");
        /*make a link to download the second result file*/
        DownloadFile(json.fileNameResult2, "application/pdf");
        };
        file_reader.readAsArrayBuffer(e.target.files[0]);
    };