17.05.2014 Views

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Fig. 8.43 Using the image matchbox to draw a frame around the image<br />

Generated output Option list for fit_image( )<br />

boxsize={60 60} position={center} fitmethod=meet<br />

matchbox={name=kraxi borderwidth=4 offsetleft=-2 offsetright=2<br />

offsetbottom=-2 offsettop=2 linecap=round linejoin=round<br />

strokecolor {rgb 0.0 0.3 0.3}}<br />

Align text at an image. The following code fragment shows how to align vertical text<br />

at the right margin of an image. The image is proportionally fit into the supplied box<br />

with a fit method of meet. The actual coordinates of the fitbox are retrieved with info_<br />

matchbox( ) and a vertical text line is placed relative to the lower right (x2, y2) corner of<br />

the fitbox. The border of the matchbox is stroked (see Figure 8.44).<br />

Cookbook A full code sample can be found in the Cookbook topic images/align_text_at_image.<br />

/* use this option list to load and fit the image */<br />

String optlist = "boxsize={300 200} position={center} fitmethod=meet " +<br />

"matchbox={name=giantwing borderwidth=3 strokecolor={rgb 0.85 0.83 0.85}}";<br />

/* load and fit the image */<br />

...<br />

/* retrieve the coordinates of the lower right (second) matchbox corner */<br />

if ((int) p.info_matchbox("giantwing", 1, "exists") == 1)<br />

{<br />

x1 = p.info_matchbox("giantwing", 1, "x2");<br />

y1 = p.info_matchbox("giantwing", 1, "y2");<br />

}<br />

/* start the text line at that corner with a small distance of 2 */<br />

p.fit_textline("Foto: Kraxi", x2+2, y2+2, "font=" + font + " fontsize=8 orientate=west");<br />

Fig. 8.44 Use the coordinates of the image matchbox to fit a text line<br />

Generated output<br />

Generation steps<br />

Foto: Kraxi<br />

(x2, y2)<br />

Step 1: Fit image with matchbox<br />

Step 2: Retrieve matchbox info for coordinates (x2, y2)<br />

Step 3: Fit text line starting at retrieved coordinates (x2, y2) with option<br />

orientate=west<br />

8.4 Matchboxes 245

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

Saved successfully!

Ooh no, something went wrong!