Add Images to PDF document via CLI

Insert images to PDF document programmatically using Aspose.PDF for Aspose.PDF CLI

Add Image to PDF Document Using CLI Tool

In order to add Image in PDF file, we’ll use Aspose.PDF CLI API which is a feature-rich, powerful and easy-to-use document manipulation API for cpp-cli platform. This CLI tool enables developers to create PDF documents quickly and efficiently through programming. It allows users to execute commands by typing them into a console or terminal window. The application is powered by the Aspose.PDF for C++ library. You can check its latest releases directly from Aspose.PDF CLI App

Add Image to PDF using CLI


You need Aspose.PDF CLI to try the code in your environment.

  1. Create a Document object and open the input PDF document.
  2. Get the page you want to add an image.
  3. Add the image into the page’s Resources collection.
  4. Use the GSave operator to save the current graphical state.
  5. Use ConcatenateMatrix operator to specify where the image is to be placed.
  6. Use the Do operator to draw the image on the page.
  7. Use GRestore operator to save the updated graphical state.
  8. Save the PDF file.

Add Image to PDF document - CLI

This sample code shows how to add Images into PDF page - CLI


    asposepdftool addimages <PDF-source-file> [-out=result-file] ..<image-file-n>