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.

6 Text Output<br />

6.1 Text Output Methods<br />

<strong>PDFlib</strong> supports text output on several levels:<br />

> Low-level text output with show( ) and similar functions;<br />

> Single-line formatted text output with fit_textline( ); This function also supports text<br />

on a path.<br />

> Multi-line text formatted output with Textflow (fit_textflow( ) and related functions);<br />

The Textflow formatter can also wrap text inside or outside of vector-based shapes.<br />

> Text in tables; the table formatter supports Textline and Textflow contents in table<br />

cells.<br />

Low-level text output. functions like show( ) can be used to place text at a specific location<br />

on the page, without using any formatting aids. This is recommended only for applications<br />

with very basic text output requirements (e.g. convert plain text files to PDF),<br />

or for applications which already have full text placement information (e.g. a driver<br />

which converts a page in another format to PDF).<br />

The following fragment creates text output with low-level functions:<br />

font = p.load_font("Helvetica", "unicode", "");<br />

p.setfont(font, 12);<br />

p.set_text_pos(50, 700);<br />

p.show("Hello world!");<br />

p.continue_text("(says Java)");<br />

Formatted single-line text output with Textlines. fit_textline( ) creates text output<br />

which consists of single lines and offers a variety of formatting features. However, the<br />

position of individual Textlines must be determined by the client application.<br />

The following fragment creates text output with a Textline. Since font, encoding,<br />

and fontsize can be specified as options, a preceding call to load_font( ) is not required:<br />

p.fit_textline(text, x, y, "fontname=Helvetica encoding=unicode fontsize=12");<br />

See Section 8.1, »Placing and Fitting Textlines«, page 199, for more information about<br />

Textlines.<br />

Multi-line text output with Textflow. fit_textflow( ) creates text output with an arbitrary<br />

number of lines and can distribute the text across multiple columns or pages. The<br />

Textflow formatter supports a wealth of formatting functions.<br />

The following fragment creates text output with Textflow:<br />

tf = p.add_textflow(tf, text, optlist);<br />

result = p.fit_textflow(tf, llx, lly, urx, ury, optlist);<br />

p.delete_textflow(tf);<br />

See Section 8.2, »Multi-Line Textflows«, page 207, for more information about Textflow.<br />

Text in tables. Textlines and Textflows can also be used to place text in table cells. See<br />

Section 8.3, »Table Formatting«, page 227, for more information about table features.<br />

6.1 Text Output Methods 151

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

Saved successfully!

Ooh no, something went wrong!