File: reference.xml

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (277 lines) | stat: -rw-r--r-- 8,663 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.23 $ -->
<!-- Purpose: utilspec.nontext -->
<!-- Membership: pecl, external -->

 <reference id="ref.pdf">
  <title>PDF &Functions;</title>
  <titleabbrev>PDF</titleabbrev>

  <partintro>
   <section id="pdf.intro">
    &reftitle.intro;
    <para>
     The PDF functions in PHP can create PDF files using the PDFlib
     library which was initially created by Thomas Merz and is now
     maintained by <ulink url="&url.pdf;">PDFlib GmbH</ulink>.
    </para>
    <para>
     The documentation in this section is only meant to be an overview
     of the available functions in the PDFlib library and should not be
     considered an exhaustive reference. For the full and detailed 
	 explanation of each function, consult the PDFlib Reference Manual
	 which is included in all PDFlib packages distributed by PDFlib GmbH.
     It provides a very good overview of what PDFlib is capable of doing
     and contains the most up-to-date documentation of all functions.
    </para>
    <para>
     For a jump start we urge you to take a look at the programming samples
     which are contained in all PDFlib distribution packages. These samples
     demonstrate basic text, vector, and graphics output as well as 
     higher-level functions, such as the PDF import facility (PDI).
    </para>
    <para>
     All of the functions in PDFlib and the PHP module have identical
     function names and parameters. Unless configured otherwise, all
     lengths and coordinates are measured in PostScript points. There are
     generally 72 PostScript points to an inch, but this depends on the 
     output resolution. Please see the PDFlib Reference Manual
     included in the PDFlib distribution for a more thorough explanation
     of the coordinate system used.
    </para>
	<para>
     With version 6, PDFlib offers an object-oriented API for PHP 5 in 
     addition to the function-oriented API for PHP 4. The main difference is
     the following:
	</para>   
    <para>
     In PHP 4, first a PDF resource has to be retrieved with a function call
     like 
    </para>   
    <para>
     $p = PDF_new().
    </para>   
    <para>
     This PDF resource is used as the first parameter in all further function
     calls, such as in
    </para>   
    <para>
     PDF_begin_document($p, "", "").
    </para>   
    <para>
     In PHP 5 however, a PDFlib object is created with
    </para>   
    <para>
	 $p = new PDFlib().
    </para>   
    <para>
     This object offers all PDFlib API functions as methods, e.g. as with
	</para>   
    <para>
     $p->begin_document("", "").
    </para>   
    <para>
     In addition, exceptions have been introduced in PHP 5 which are
     supported by PDFlib 6 and later as well.
	</para>   
    <para> 
     Please see the <link linkend="pdf.examples">examples</link> below for
	 more information.
    </para>
    <note>
     <para>
      If you're interested in alternative free PDF generators that do not 
      utilize external PDF libraries, see <link linkend="faq.using.freepdf">
      this related FAQ</link>.
     </para>
    </note>
   </section>

   <section id="pdf.requirements">
    &reftitle.required;
    <para>
     PDFlib Lite is available as open source. However, the
     PDFlib Lite license allows free use only under certain conditions.
     PDFlib Lite supports a subset of PDFlib's functionality; please see the
     PDFlib web site for details. The full version of PDFlib is available for
     download at <ulink url="&url.pdf;">&url.pdf;</ulink>, but requires that
     you purchase a license for commercial use.
    </para>
   </section>

   <section id="pdf.oldlibs.hints">
    <title>Issues with older versions of PDFlib</title>
    <para>
     Any version of PHP 4 after March 9, 2000 does not support versions
     of PDFlib older than 3.0.
    </para>
    <para>
     PDFlib 4.0 or greater is supported by PHP 4.3 and later.
    </para>
   </section>

   &reference.pdf.configure;

   <section id="pdf.resources">
    &reftitle.resources;
    &no.resource;
   </section>

   <section id="pdf.oldlibs">
    <title>Remarks about Deprecated PDFlib Functions</title> 
   <para>
    Starting with PHP 4.0.5, the PHP extension for PDFlib is
    officially supported by PDFlib GmbH. This means that all the
    functions described in the PDFlib Reference Manual are
    supported by PHP 4 with exactly the same meaning and the same
    parameters. However, with PDFlib Version 5.0.4 or higher all parameters
	have to be specified. For compatibility reasons, this binding for PDFlib
    still supports most of the deprecated functions, but they
    should be replaced by their new versions. PDFlib GmbH will not
    support any problems arising from the use of these deprecated
    functions. The documentation in this section indicates old functions as
	"Deprecated" and gives the replacement function to be used instead. 
   </para>
   </section>

   <section id="pdf.examples">
    &reftitle.examples;
    <para>
     Most of the functions are fairly easy to use. The most difficult part
     is probably creating your first PDF document. The following
     example should help to get you started. It is developed for PHP 4 and 
     creates the file <filename>hello.pdf</filename> with one page.
	 It defines some document info field contents, loads the Helvetica-Bold
	 font and outputs the text "Hello world! (says PHP)".
    </para>
    <para>
     <example>
      <title>Hello World example from PDFlib distribution for PHP 4</title>
      <programlisting role="php">
<![CDATA[
<?php
$p = PDF_new();

/*  open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
    die("Error: " . PDF_get_errmsg($p));
}

PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "Hello world (PHP)!");

PDF_begin_page_ext($p, 595, 842, "");

$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");

PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page_ext($p, "");

PDF_end_document($p, "");

$buf = PDF_get_buffer($p);
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;

PDF_delete($p);
?>
]]>
      </programlisting>
     </example>
    </para>
	   
    <para>
     The following example comes with the PDFlib distribution for PHP 5.
	 It uses the new exception handling and object encapsulation features
	 available in PHP 5. It creates the file <filename>hello.pdf</filename>
     with one page. It defines some document info field contents, loads the
     Helvetica-Bold font and outputs the text "Hello world! (says PHP)".
    </para>
    <para>
     <example>
      <title>Hello World example from PDFlib distribution for PHP 5</title>
      <programlisting role="php">
<![CDATA[
<?php

try {
    $p = new PDFlib();

    /*  open new PDF file; insert a file name to create the PDF on disk */
    if ($p->begin_document("", "") == 0) {
        die("Error: " . $p->get_errmsg());
    }

    $p->set_info("Creator", "hello.php");
    $p->set_info("Author", "Rainer Schaaf");
    $p->set_info("Title", "Hello world (PHP)!");

    $p->begin_page_ext(595, 842, "");

    $font = $p->load_font("Helvetica-Bold", "winansi", "");

    $p->setfont($font, 24.0);
    $p->set_text_pos(50, 700);
    $p->show("Hello world!");
    $p->continue_text("(says PHP)");
    $p->end_page_ext("");

    $p->end_document("");

    $buf = $p->get_buffer();
    $len = strlen($buf);

    header("Content-type: application/pdf");
    header("Content-Length: $len");
    header("Content-Disposition: inline; filename=hello.pdf");
    print $buf;
}
catch (PDFlibException $e) {
    die("PDFlib exception occurred in hello sample:\n" .
	"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
	$e->get_errmsg() . "\n");
}
catch (Exception $e) {
    die($e);
}
$p = 0;
?>
]]>
      </programlisting>
     </example>
    </para>
   </section>
  </partintro>

  &reference.pdf.functions;

 </reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->