php-doc-en/reference/pdf/functions/pdf-open-file.xml
2004-08-13 12:05:17 +00:00

79 lines
2.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/pdf.xml, last change in rev 1.42 -->
<refentry id="function.pdf-open-file">
<refnamediv>
<refname>pdf_open_file</refname>
<refpurpose>Opens a new pdf object</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>pdf_open_file</methodname>
<methodparam><type>resource</type><parameter>pdfdoc</parameter></methodparam>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Create a new PDF file using the supplied file name.
If <parameter>filename</parameter> is empty the PDF document
will be generated in memory instead of on file. The result
must be fetched by the client with the
<function>pdf_get_buffer</function> function.
Parameter <parameter>filename</parameter> was optional before PHP 5.
&return.success;
</para>
<para>
The following example shows how to create a pdf document in memory
and how to output it correctly.
<example>
<title>Creating a PDF document in memory</title>
<programlisting role="php">
<![CDATA[
<?php
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_begin_page($pdf, 595, 842);
pdf_set_font($pdf, "Times-Roman", 30, "host");
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "A PDF document created in memory!", 50, 750);
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-disposition: inline; filename=test.pdf");
header("Content-length: " . strlen($data));
echo $data;
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- 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
-->