<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >printer_set_option</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Printer Functions" HREF="ref.printer.html"><LINK REL="PREVIOUS" TITLE="printer_select_pen" HREF="function.printer-select-pen.html"><LINK REL="NEXT" TITLE="printer_start_doc" HREF="function.printer-start-doc.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.printer-select-pen.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.printer-start-doc.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.printer-set-option" ></A >printer_set_option</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN188539" ></A ><P > (PECL)</P >printer_set_option -- Configure the printer connection</DIV ><DIV CLASS="refsect1" ><A NAME="AEN188542" ></A ><H2 >Description</H2 >bool <B CLASS="methodname" >printer_set_option</B > ( resource handle, int option, mixed value )<BR ></BR ><P > The function sets the following options for the current connection. <CODE CLASS="parameter" >handle</CODE > must be a valid handle to a printer. For <CODE CLASS="parameter" >option</CODE > can be one of the following constants: <P ></P ><UL ><LI ><P > <CODE CLASS="parameter" >PRINTER_COPIES</CODE >: sets how many copies should be printed, <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_MODE</CODE >: specifies the type of data (text, raw or emf), <CODE CLASS="parameter" >value</CODE > must be a string. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TITLE</CODE >: specifies the name of the document, <CODE CLASS="parameter" >value</CODE > must be a string. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_ORIENTATION</CODE >: specifies the orientation of the paper, <CODE CLASS="parameter" >value</CODE > can be either PRINTER_ORIENTATION_PORTRAIT or PRINTER_ORIENTATION_LANDSCAPE </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_RESOLUTION_Y</CODE >: specifies the y-resolution in DPI, <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_RESOLUTION_X</CODE >: specifies the x-resolution in DPI, <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_PAPER_FORMAT</CODE >: specifies a predefined paper format, set <CODE CLASS="parameter" >value</CODE > to PRINTER_FORMAT_CUSTOM if you want to specify a custom format with PRINTER_PAPER_WIDTH and PRINTER_PAPER_LENGTH. <CODE CLASS="parameter" >value</CODE > can be one of the following constants. </P ><P ></P ><UL ><LI ><P > <CODE CLASS="parameter" > PRINTER_FORMAT_CUSTOM</CODE >: let's you specify a custom paper format. </P ></LI ><LI ><P > <CODE CLASS="parameter" > PRINTER_FORMAT_LETTER</CODE >: specifies standard letter format (8 1/2- by 11-inches). </P ></LI ><LI ><P > <CODE CLASS="parameter" > PRINTER_FORMAT_LEGAL</CODE >: specifies standard legal format (8 1/2- by 14-inches). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_A3</CODE >: specifies standard A3 format (297- by 420-millimeters). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_A4</CODE >: specifies standard A4 format (210- by 297-millimeters). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_A5</CODE >: specifies standard A5 format (148- by 210-millimeters). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_B4</CODE >: specifies standard B4 format (250- by 354-millimeters). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_B5</CODE >: specifies standard B5 format (182- by 257-millimeter). </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_FORMAT_FOLIO</CODE >: specifies standard FOLIO format (8 1/2- by 13-inch). </P ></LI ></UL ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_PAPER_LENGTH</CODE >: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_LENGTH specifies a custom paper length in mm, <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_PAPER_WIDTH</CODE >: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_WIDTH specifies a custom paper width in mm, <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_SCALE</CODE >: specifies the factor by which the printed output is to be scaled. the page size is scaled from the physical page size by a factor of scale/100. for example if you set the scale to 50, the output would be half of its original size. <CODE CLASS="parameter" >value</CODE > must be an integer. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_BACKGROUND_COLOR</CODE >: specifies the background color for the actual device context, <CODE CLASS="parameter" >value</CODE > must be a string containing the rgb information in hex format i.e. "005533". </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TEXT_COLOR</CODE >: specifies the text color for the actual device context, <CODE CLASS="parameter" >value</CODE > must be a string containing the rgb information in hex format i.e. "005533". </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TEXT_ALIGN</CODE >: specifies the text alignment for the actual device context, <CODE CLASS="parameter" >value</CODE > can be combined through OR'ing the following constants: </P ><P ></P ><UL ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_BASELINE</CODE >: text will be aligned at the base line. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_BOTTOM</CODE >: text will be aligned at the bottom. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_TOP</CODE >: text will be aligned at the top. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_CENTER</CODE >: text will be aligned at the center. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_LEFT</CODE >: text will be aligned at the left. </P ></LI ><LI ><P > <CODE CLASS="parameter" >PRINTER_TA_RIGHT</CODE >: text will be aligned at the right. </P ></LI ></UL ></LI ></UL > </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN188660" ></A ><P ><B >例 1. <B CLASS="function" >printer_set_option()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$handle </font><font color="#007700">= </font><font color="#0000BB">printer_open</font><font color="#007700">();<br /></font><font color="#0000BB">printer_set_option</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">, </font><font color="#0000BB">PRINTER_SCALE</font><font color="#007700">, </font><font color="#0000BB">75</font><font color="#007700">);<br /></font><font color="#0000BB">printer_set_option</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">, </font><font color="#0000BB">PRINTER_TEXT_ALIGN</font><font color="#007700">, </font><font color="#0000BB">PRINTER_TA_LEFT</font><font color="#007700">);<br /></font><font color="#0000BB">printer_close</font><font color="#007700">(</font><font color="#0000BB">$handle</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.printer-select-pen.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.printer-start-doc.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >printer_select_pen</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.printer.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >printer_start_doc</TD ></TR ></TABLE ></DIV ></BODY ></HTML >