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

Create successful ePaper yourself

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

do<br />

{<br />

String optlist = "verticalalign=justify linespreadlimit=120%";<br />

p.begin_page_ext(0, 0, "width=a4.width height=a4.height");<br />

/* Fill the first column */<br />

result = p.fit_textflow(tf, llx1, lly1, urx1, ury1, optlist);<br />

/* Fill the second column if we have more text*/<br />

if (!result.equals("_stop"))<br />

result = p.fit_textflow(tf, llx2, lly2, urx2, ury2, optlist);<br />

p.end_page_ext("");<br />

/* "_boxfull" means we must continue because there is more text;<br />

* "_nextpage" is interpreted as "start new column"<br />

*/<br />

} while (result.equals("_boxfull") || result.equals("_nextpage"));<br />

/* Check for errors */<br />

if (!result.equals("_stop"))<br />

{<br />

/* "_boxempty" happens if the box is very small and doesn't hold any text at all.<br />

*/<br />

if (result.equals( "_boxempty"))<br />

throw new Exception("Error: " + p.get_errmsg());<br />

else<br />

{<br />

/* Any other return value is a user exit caused by the "return" option;<br />

* this requires dedicated code to deal with.<br />

*/<br />

}<br />

}<br />

p.delete_textflow(tf);<br />

8.2.2 Paragraph Formatting Options<br />

In the previous example we used default settings for the paragraphs. For example, the<br />

default alignment is left-justified, and the leading is 100% (which equals the font size).<br />

In order to fine-tune the paragraph formatting we can feed more options to add_<br />

textflow( ). For example, we can indent the text 15 units from the left and 10 units from<br />

the right margin. The first line of each paragraph should be indented by an additional<br />

20 units. The text should be justified against both margins, and the leading increased to<br />

140%. Finally, we’ll reduce the font size to 8 points. To achieve this, extend the option<br />

list for add_textflow( ) as follows (see Figure 8.15):<br />

String optlist =<br />

"leftindent=15 rightindent=10 parindent=20 alignment=justify " +<br />

"leading=140% fontname=Helvetica fontsize=8 encoding=unicode";<br />

8.2.3 Inline Option Lists and Macros<br />

The text in Figure 8.15 is not yet perfect. The headline »Have a look at our new paper<br />

plane models!« should sit on a line of its own, should use a larger font, and should be<br />

centered. There are several ways to achieve this.<br />

210 Chapter 8: Text and Table Formatting (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)

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

Saved successfully!

Ooh no, something went wrong!