AddImage

<< Click to Display Table of Contents >>

Navigation:  Tasks > Draw Shapes / Text objects on PDF >

AddImage

This method prints (stamps) a JPEG image which was embedded by AddImage / command COMPDF_AddJPEG:

 

function Plus.UseImage(const ImageID, PageNo: Integer; x, y, w, h,

  angle: Integer; PosMode: TWPImagePosMode) : Boolean;

 

The same can be done with command COMPDF_ImagePrint

 

Parameters:

const ImageID:        the id returned by AddImage (value is > 0!)

PageNo:                the page number, zero based! (0..)

x, y, w, h:                the position and size in measured 72 dpi or values in %

angle:                        an optional angle in degree

PosMode:                the position mode:

 

This set includes flags which change the way the image is positioned.

It is possible to specify the width as % of the page width and also center an image to the page.

 

  1: wpAtPageHorzCenter                Center the Image horizontally

  2: wpAtPageVertCenter                Center the Image vertically

  4 : wpPageWidthPC                Set width as % value of Page Width

  8: wpPageHeightPC                Set height as % value of Page Width

  16: wpFillPageAspectRatio        Fill the page with image but keep w/h aspect ratio

  32: wpAtPagePageRight                Use x as offset from the right of page

  64: wpAtPageBottom                 Use y as offset from bottom of page

  128: wpTilePage                        Tile the image on the page (only use w and h)

  256: wpUnderPage                place the image under the page text, default is above text.

  512: wpXYIsImageCenter        Use the passed x,y as center of the image

  1024: wpRotateToPage                Rotate the image in the same direction as the page

 

This method can be also called using command COMPDF_ImagePrint = 321.

This command requires a structur as parameter:

 

TPDFPrintImageRec = struct

{

   int ImageID;

   int PageNo;

   int x,y,w,h;

   int PosMode;

   int angle;

}

 

PosMode is handled as bitfield (wpAtPageHorzCenter=1, wpAtPageVertCenter=2 ... wpUnderPage=256)

 

Pascal Example:

 

WPViewPDF1.Plus.UseImage(ImageID, 0, 0, 0, 0, 0, 0,

  [wpAtPageHorzCenter, wpAtPageVertCenter,

     wpPageWidthPC, wpPageHeightPC, wpUnderPage]);

 

 

Exampe:

Result := View.CommandEx(COMPDF_ImagePrint,  (DWORD)@PDFPrintImageRec);

 

It is possible to use this commands to later hide and display certain images using this commands:

 

COMPDF_ImageSetHidden          = 323 : param = ID, hide image with ID param (all inserted positions).

   this command may be called with a string parameter "on", "off" and "toggle"

 

COMPDF_ImageSetDisplayed       = 324: param = ID, show image with ID param (all inserted positions)