Dicontek abis dari sini :
http://www.tek-tips.com/viewthread.cfm?qid=1376830&page=1
I was able to run the php code and save the output as a plain html file. I then sent the html file to the printer. However, all my testing was done on screen to save paper. As mentioned above, it just sent the raw unrendered html source code to the printer.
I have spent way too much time on this... so for now the report is just going to have to be run manually. Thanks to all for your comments and input.
jet042 (MIS)
15 Jun 07 17:02
Well, I was finally able to get this to work. I don't know if it will do what you want, but here is the code that I used in my tests.
CODE --> print_test.php
$fhandle = fopen("test.php","rb");
$contents = fread($fhandle, filesize("test.php"));
$output = eval($contents);
$handle = printer_open("Dell Laser Printer M5200");
printer_set_option($handle,PRINTER_MODE,"raw");
printer_write($handle,$output);
printer_close($handle);
?>
CODE --> test.php
$now = time();
return $now;
Notice that test.php does not have open or closing tags. It also returns all it's output at once. I did not experiment with formating the output, but you might be able to include some non-printing control characters for your printer to do that. In all, it's probably more work than you want to put in.
DustDevil1980 (Programmer)
15 Jun 07 17:08
That does work for simple text, but this report is sent to our customers, so it needs formating and grpahics included with it.
I will keep this on hand for other reports that do not require formating.
webdev007 (Programmer)
15 Jun 07 18:42
You may use file_get_contents()
for ex:
load a URL (full path) to the test.php anywhere on your server
then point file_get_contents to that URL
and it should properly parse your PHP
DustDevil1980 (Programmer)
15 Jun 07 18:47
That will only parse to the screen and not to the printer.
jpadie (TechnicalUser)
15 Jun 07 18:48
here is the way that I would do it. Using output buffering to store the evaluated code. I have found this technique very useful on a number of occasions
CODE
$filename = "test.php";
///////
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
///////
$handle = printer_open("SAVIN4045ePCL6");
printer_set_option($handle, PRINTER_MODE, "raw");
printer_write($handle,$contents);
printer_close($handle);
?>
Senin, 13 Desember 2010
Rabu, 08 Desember 2010
Fieldset CSS & Google font API
http://apps.wittysparks.com/jquery/fieldset.html
Langganan:
Komentar (Atom)
