Extract images from PDF in JavaScript via C++

How to Extract images from PDF using JavaScript via C++

How to extract images from PDF using Aspose.PDF for JavaScript via C++ Tool

Do you need to extract a PDF? The Aspose.PDF for JavaScript via C++ helps extract images from PDF document. In order to extract, 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.

Extract images from PDF in 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 an XImage object to extract images.
  3. Save output image to jpeg file.
  4. Save updated PDF file.

Extract images from PDF - JavaScript via C++

This sample code shows how to extract images from PDF documents

Input file:

File not added

Output format:

PDF

Output file:


    var ffileExtractImage = function (e) {
        const file_reader = new FileReader();
        file_reader.onload = (event) => {
        /*Extract image from a PDF-file with template "ResultPdfExtractImage{0:D2}.jpg" ({0}, {0:D2}, {0:D3}, ... format page number), resolution 150 DPI and save*/
        const json = AsposePdfExtractImage(event.target.result, e.target.files[0].name, "ResultPdfExtractImage{0:D2}.jpg", 150);
        if (json.errorCode == 0) {
            document.getElementById('output').textContent = "Files(images) count: " + json.filesCount.toString();
            /*Make links to result files*/
            for (let fileIndex = 0; fileIndex < json.filesCount; fileIndex++) DownloadFile(json.filesNameResult[fileIndex], "image/jpeg");
        }
        else document.getElementById('output').textContent = json.errorText;
        }
        file_reader.readAsArrayBuffer(e.target.files[0]);
    }

About Aspose.PDF for JavaScript via C++ API

Aspose.PDF for JavaScript via C++ allows developers manipulate them PDF files directly in the Web. This JavaScript Solution is built on the use of WebAssembly technology and is based on Aspose.PDF for C++. You can easily use Aspose.Pdf for JavaScript via C++ from and then follow the installation instructions. The Aspose.PDF for JavaScript supports a wide variety of functions such as:

  • Optimize PDF document.
  • Add a stamp to PDF file.
  • Merge PDF files.
  • Split PDF to two files.
  • Convert PDF to DOCX, XLSX, JPEG, PNG, TIFF, BMP, SVG, SVG(ZIP), XPS, TXT, and etc.

You can find more information about Aspose.PDF for JavaScript via C++ API on our documentation on how to use API.