note 60728 added to function.printer-draw-bmp

From: Date: Sun, 15 Jan 2006 10:51:12 +0000
Subject: note 60728 added to function.printer-draw-bmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-101794@lists.php.net to get a copy of this message
When trying to print any image file it was getting a very, very small as someone said above. To solve this problem, ive made a script that will calculate the correct size of image before output it to printer. Most of InkJet printers use 300 dpi. You can change values if you have any other printer... In this case, im using a HP DeskJet 930c. To make this script better, you can use GD to discover image resolution automatically. <?php $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $largura = 415; //Image Width in Pixels $altura = 284; //Image Height in Pixels $fator_x = $largura / 72; //Image Resolution (72 ppi) $fator_y = $largura / 300; //Printer Resolution (300 dpi) $fator_z = $fator_x / $fator_y; $largura_f = $largura * $fator_z; $altura_f = $altura * $fator_z; printer_set_option($handle, PRINTER_MODE, "RAW"); printer_draw_bmp($handle, "c:\image.bmp", 1, 1, $largura_f, $altura_f); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); ?> ---- Manual Page -- http://www.php.net/manual/en/function.printer-draw-bmp.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60728 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60728&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60728&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101794) next »