Skip to Content

How do I insert an image into a PDF document?

Estimated Reading Time: 1 Minutes

In DLI, if you know the width and depth of the image, and its color space, you can use dlpdfimagecreatefrombmp() to insert an image in a PDF document. There is a sample of this in the DLI Sample Graphics. You may also use dlpdfimagecreatefromfile() to convert an external image to a DLI image.

The bitmap may not be compressed. It is presumed to proceed from left to right and from bottom to top. Otherwise, a matrix may be used at image use time to correct it. If its colors are RGB, they must be in that order. This interface presumes the bitmap is in memory. If it is not, it must be read in using file system calls.

dlpdfimagecreatefromcompbmp() permits the image to be compressed prior to creation, and also allows for “flipping” the image horizontally or vertically.

You can create the same thing in the Adobe PDF Library using PDEImageCreate(). In this case, the data is presumed to be in an ASStm object. This object can be easily created for a block of memory using ASMemStmRdOpen(), or for an external file using ASFileSysOpenFile() andASFileStmRdOpen(). This method will also permit you to read a compressed bitmap without expanding it.

Depending on the size of your images and your pages, you may place one image per page, or combine several into one page. The Library will create the images for you and will display them in a page at the location you specify. Deciding how many images will fit on a page and where on the page to put them, is the responsibility of your application. 

Adobe PDF Library Java and .NET Interface also provides a sample program that demonstrates how to import images. See ImageImport sample for .NET (also available for Java and .NET Framework).

How do I insert an image into a PDF document?
  • COMMENT