Specifications

pdf_set_font($pdf, “Helvetica-Bold”, 24, “host”);
Font sizes are specified in points. We have chosen host character encoding. The allowable val-
ues are winansi, builtin, macroman, ebcdic, or host. The meanings of the different values are as
follows:
winansiISO 8859-1 plus special characters added by Microsoft such as a Euro symbol.
macromanMac Roman encoding. The default Macintosh character set.
ebcdicEBCDIC as used on IBM AS/400 systems.
builtinUse the encoding built in to the font. Normally used with non Latin fonts and
symbols.
hostAutomatically selects macroman on a Mac, ebcdic on an EBCDIC-based system,
and winansi on all other systems.
If you do not need to include special characters, the choice of encoding is not important.
A PDF document is not like an HTML document or a word processor document. Text does not
simply start at the top left and flow onto other lines as required. We need to choose where to
place each line of text. As already mentioned, PDF uses points to specify locations. The origin
(the x, y coordinate [0, 0]) is at the bottom left corner of the page.
Given that our page is 612 by 792 points, the point (50, 700) is about two thirds of an inch
from the left of the page and about one and one third inches from the top. To set our text
position at this point, we use
pdf_set_text_pos($pdf, 50, 700);
Finally, having set up the page, we can write some text on it. To add text at the current position
using the current font, we use pdf_show().
The line
pdf_show($pdf,”Hello,world!”);
adds the test “Hello World!” to our document.
To move to the next line and write more text, we use
pdf_continue_text(). To add the string
“(says PHP)”, we use
pdf_continue_text($pdf,”(says PHP)”);
The exact location where this will appear will depend on the font and size selected.
When we have finished adding elements to a page, we need to call
pdf_end_page() as follows:
pdf_end_page($pdf);
Generating Personalized Documents in Portable Document Format (PDF)
C
HAPTER 30
30
GENERATING
PERSONALIZED
DOCUMENTS IN
PDF
769
36 7842 CH30 3/6/01 3:40 PM Page 769