10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

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.

7 Formatting Features7.1 Placing and Fitting Single-Line TextThe function PDF_fit_textline( ) for placing a single line of text on a page offers a wealthof formatting options. The most important options will be discussed in this section usingsome common application examples. A complete description of these options canbe found in the PDFlib Reference. Most options for PDF_fit_textline( ) are identical to thoseof PDF_fit_image( ). Therefore we will only use text-related examples here; it is recommendedto take a look at the examples in Section 7.3, »Placing Images and Imported PDFPages«, page 158, for an introduction to image formatting.The examples below demonstrate only the relevant call of PDF_fit_textline( ), assumingthat the required font has already been loaded and set in the desired font size.PDF_fit_textline( ) uses a hypothetical text box to determine the positioning of thetext: the width of the text box is identical to the width of the text, and the box height isidentical to the height of capital letters in the font. The text box can be extended to theleft and right or top and bottom using the margin option. The margin will be scaledalong with the text line.In the examples below, the coordinates of the reference point are supplied as x, y parametersof PDF_fit_textline( ). The fitbox for text lines is the area where text will beplaced. It is defined as the rectangular area specified with the x, y parameters of PDF_fit_textline( ) and appropriate options (boxsize, position, rotate).Cookbook Code samples regarding text output issues can be found in the text_output category of thePDFlib Cookbook.7.1.1 Simple Text PlacementPositioning text at the reference point. By default, the text will be placed with the lowerleft corner at the reference point. However, in this example we want to place the textwith the bottom centered at the reference point. The following code fragment placesthe text box with the bottom centered at the reference point (30, 20).p.fit_textline(text, 30, 20, "position={center bottom}");Figure 7.1 illustrates centered text placement. Similarly, you can use the position optionwith another combination of the keywords left, right, center, top, and bottom to placetext at the reference point.Fig. 7.1Centered textyKraxiyKraxiFig. 7.2Simple text withorientation westxx7.1 Placing and Fitting Single-Line Text 133

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

Saved successfully!

Ooh no, something went wrong!