Before working with a PDF document, make sure to initialize the PDF component (see Getting Started with PDF).
Refer to the AddNewPageWithImage Sample and the AddWatermarksToPDF Sample for complete sample code that illustrates how to use these capabilities.
You can add images to a PDF document using the PDF editing layer, which is implemented via "PDE" objects (for example, HIG_PDE_CONTENT). This topic walks you through how to...
In order to add an image to a PDF page, a PDE version of the image has to be created first, using IG_PDE_image_create. The code snippet below demonstrates how to do this for a 24-bit RGB image, preparing the pixel data, color space, compression, image attributes and transformation matrix. For a more elaborate example with support for other bit depths and additional options, please see the AddNewPageWithImage sample.
The following steps summarize the preparation of the input parameters, and then creating the PDE image accordingly.
The following code snippet demonstrates this:
If the image has an alpha channel, a separate 8-bit grayscale image has to be created for it using IG_PDE_image_create, and linked to the PDE image using IG_PDE_image_set_soft_mask. See the AddNewPageWithImage sample for an example of how this can be done.
Now that we have a way to create a PDE image, we can add it to the PDF. The following steps summarize how to gain access to the content of a PDF page and add the newly created PDE image.
The following code snippet demonstrates this:
See also the section Watermarks and Annotations in a PDF.