downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

printer_abort> <PDO::pgsqlLOBUnlink
[edit] Last updated: Mon, 01 Nov 2010

view this page in

CXXVII. Drucker Funktionen

Einführung

Diese Funktionen sind nur unter Windows 9.x, ME, NT4 und 2000 verfügbar. Sie wurden in PHP Version 4.0.4 hinzugefügt.

Installation

Diese » PECL Erweiterung ist nicht Teil von PHP. Zusätzliche Informationen, wie neue Releases, Downloads Quelldateien, Maintainerinformation und ein CHANGELOG finden Sie hier: » http://pecl.php.net/package/printer.

Windows User müssen php_printer.dll in php.ini aktivieren, um diese Funktionen zu benutzen. Für PHP 4 finden Sie die DLL im extensions/ Verzeichnis der PHP Windows Binärdistribution. Sie können die DLL für diese PECL Erweiterung entweder von » PHP Downloads oder von » http://snaps.php.net/ herunterladen.

Laufzeit Konfiguration

Das Verhalten dieser Funktionen wird durch Einstellungen in der php.ini beeinflusst.

Tabelle 225. Drucker Einstellungsoptionen

NameStandardÄnderbar
printer.default_printer""PHP_INI_ALL

Weitere Details und die Definition der PHP_INI_* Konstanten sind unter ini_set() zu finden.

Inhaltsverzeichnis

printer_abort — Löscht den Druckauftrag des Druckers
printer_close — Schließt eine offene Druckerverbindung
printer_create_brush — Erstellt einen neuen Pinsel
printer_create_dc — Erstellt einen Gerätekontext
printer_create_font — Erstellt eine neue Schrift
printer_create_pen — Erstellt einen neuen Stift
printer_delete_brush — Löscht einen Pinsel
printer_delete_dc — Löscht einen Gerätekontext
printer_delete_font — Löscht eine Schrift
printer_delete_pen — Löscht einen Stift
printer_draw_bmp — Zeichnet ein BMP
printer_draw_chord — Draw a chord
printer_draw_elipse — Zeichnet eine Ellipse
printer_draw_line — Zeichnet eine Linie
printer_draw_pie — Draw a pie
printer_draw_rectangle — Zeichnet ein Rechteck
printer_draw_roundrect — Zeichnet ein Rechteck mit abgerundeten Ecken
printer_draw_text — Zeichnet einen text
printer_end_doc — Schließt ein Dokument
printer_end_page — Schließt die aktive Seite
printer_get_option — Liest Einstellungen des Druckers
printer_list — Liefert ein Array von Zeigern auf den Server zurück
printer_logical_fontheight — Berechnet die logische Schrifthöhe
printer_open — Erstellt eine Verbindung zu einem Drucker
printer_select_brush — Wählt einen Pinsel aus
printer_select_font — Wählt eine Schrift aus
printer_select_pen — Wählt einen Stift aus
printer_set_option — Konfiguriert die Druckerverbindungn
printer_start_doc — Beginnt ein neues Dokument
printer_start_page — Beginnt eine neue Seite
printer_write — Sendet Daten an den Drucker


printer_abort> <PDO::pgsqlLOBUnlink
[edit] Last updated: Mon, 01 Nov 2010
 
add a note add a note User Contributed Notes Drucker Funktionen
php at mailinator dot com 19-Feb-2009 07:17
If you want to print to a network printer on another machine:

If you are running PHP on a web server that is running as the System user (quite likely), it won't have access to network resources, including network printers. Changing the web server service to run as an account with access to network printers fixes the issue.
extremesanity 30-May-2007 01:35
I have gotten very reliable printing using this set of functions coupled with Windows 2000, IIS, the PECL extension, and the php_printer.dll.

Basically I have a linux web server that sends a request to the windows 2000 IIS web server (acting as the role of print server) sending the information to be printed in the query string.

I use this primarily for printing barcoded labels, where the barcode itself is a barcode font found on the web. 

I got terrible reliability out of all versions of apache running on windows 2000 and xp.
mdwyer at timestreamtech dot com 24-Jan-2007 03:06
I was able to print nice looking reports (under unix) by sending out formatted text out through 'enscript'.  The various configuration options on enscript took care of fonts and headers etc.  The result was a postscript file which I just sent to the server's local printer.

One could also pipe it through a PS to PDF filter and send it back to the user, I suppose.

For another job, I learned how to write postscript and just wrote directly to postscript files.  Learning how to write postscript is probably only marginally harder than learning how to use this API, and is probably more portable.
arne dot briesenick at soxabo dot de 28-Sep-2004 07:42
Printing in UN*X is possible too:

<?php
function lpr($STR,$PRN) {
 
$prn=(isset($PRN) && strlen($PRN))?"$PRN":C_DEFAULTPRN ;
 
$CMDLINE="lpr -P $prn ";
 
$pipe=popen("$CMDLINE" , 'w' );
  if (!
$pipe) {print "pipe failed."; return ""; }
 
fputs($pipe,$STR);
 
pclose($pipe);
}
// lpr()
?>

You pipe the stream/string/char/sign whatever to the system. In the example shown above you have to add at least the string for printing in the function call. The second arg is a printer name which if you don't set will be set to the C_DEFAULTPRN. This is a constant definition from an ini file.

Hope this will help to save a lot of time ;-)
jason at matteson dot com 11-Mar-2004 03:01
You can print in XP. AND, you can print to a shared printer with XP. The drivers for the printer MUST be installed on ther server as well as on the computer you wish to print with. Also, the printer must be shared on the client computer.

I am using a Zebra LP2844 Thermal Barcode Printer in my application. I am running XP Pro,Apache 1.3.27, PHP 4.3+.

Here is a function I use in our churches checkin system.  I use this to print directly to our printer with out having to use any Javascript.

First, i give the function the name of the shared printer.

Second, I get the client computers host name. You could use just REMOTE_ADDR too I suppose.

Then I return a correctly formatted Windows path to the shared printer for the

function getPrinter($SharedPrinterName) {
    global $REMOTE_ADDR;
    $host  =  getHostByAddr($REMOTE_ADDR);
    return "\\\\".$host."\\".$SharedPrinterName;
}

$handle  =  printer_open(getPrinter("Eltron"));

So, as long as you KNOW the computers are suppose to have a shared printer called "Eltron", you're all set to start sending info to the printer with the other Printer functions.

-j
macagomez at yahoo dot com 27-Jul-2003 02:35
Please notice that what is printed is NOT measured in pixels, it is measured in pronter's dots.
Apply to fonts, coordinates and bit maps.
jwlash at acm dot org 19-Feb-2003 11:40
I have noticed the for unix based systems you can also do this:

system("lp $filename")

:)
bertATnerdstockDOTorg 20-Jan-2003 04:22
If you want to address the printer from your PHP-application in a Un*x environment:
This is possible if you use a different method.
In Unix it would not be logical to address your printer directly from php, but you could for instance generate a PDF-file with PDFlib (or a textfile, or a PNG/JPEG image with GD or what have you) and write it from your php-script to a directory that you use as a "printer-outbox."

Next, you write a shellscript that calls some unix tool to print all pdf or other documents in your "outbox" directory and then deletes all files in that directory.

Then you use crontab to run this script every minute or as often as you think it's neccessary.

You could of course also call the shellscript from your php-application with exec() but you'll probably want to avoid using exec() and the like for security reasons.

 
show source | credits | sitemap | contact | advertising | mirror sites