10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.3 Placing Images and Imported PDF PagesThe function PDF_fit_image( ) for placing raster image and templates as well as PDF_fit_pdi_page( ) for placing imported PDF pages offer a wealth of options for controlling theplacement on the page. This section demonstrates the most important options by lookingat some common application tasks. A complete list and descriptions of all optionscan be found in the PDFlib Reference.Embedding raster images is easy to accomplish with PDFlib. The image file must firstbe loaded with PDF_load_image( ). This function returns an image handle which can beused along with positioning and scaling options in PDF_fit_image( ).Embedding imported PDF pages works along the same line. The PDF page must beopened with PDF_open_pdi_page( ) to retrieve a page handle for use in PDF_fit_pdi_page( ). The same positioning and scaling options can be used as for raster images.All samples in this section work the same for raster images, templates, and importedPDF pages. Although code samples are only presented for raster images we talk aboutplacing objects in general. Before calling any of the fit functions a call to PDF_load_image( ) or PDF_open_pdi_document( ) and PDF_open_pdi_page( ) must be issued. For thesake of simplicity these calls are not reproduced here.Cookbook Code samples regarding images and imported PDF pages issues can be found in the images andpdf_import categories of the PDFlib Cookbook.7.3.1 Simple Object PlacementPositioning an image at the reference point. By default, an object will be placed in itsoriginal size with the lower left corner at the reference point. In this example we willplace an image with the bottom centered at the reference point. The following codefragment places the image with the bottom centered at the reference point (0, 0).p.fit_image(image, 0, 0, "position={center bottom}");Similarly, you can use the position option with another combination of the keywordsleft, right, center, top, and bottom to place the object at the reference point.Placing an image with scaling.modifying its size:The following variation will place the image whilep.fit_image(image, 0, 0, "scale=0.5");This code fragment places the object with its lower left corner at the point (0, 0) in theuser coordinate system. In addition, the object will be scaled in x and y direction by ascaling factor of 0.5, which makes it appear at 50 percent of its original size.Cookbook A full code sample can be found in the Cookbook topic images/starter_image.7.3.2 Positioning an Object in a BoxIn order to position an object, an additional box with predefined width and height canbe used. Figure 7.27 shows the output of the examples described below. Note that theblue box or line is depicted for visualising the box size; it is not part of the actual output.158 Chapter 7: Formatting Features

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!