Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 23-10-2003, 05:02 AM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
Print Document

alow... ade sesape leh tolong aku dok. aku gagal menyetelkan masalah aku untuk mem'print' sebarang document melalui php code aku ni.

PHP Code:
//print_test.php

$print_doc "C:\doc_to_print.txt";
//$network_printer = "\\\\DESIGNDEPT\\HP1220C";
$list_printers printer_list(PRINTER_ENUM_LOCAL PRINTER_ENUM_SHARED);
$printer_name $list_printers[0]["NAME"];

$handle printer_open($printer_name);
//$handle = printer_open($network_printer);
printer_start_doc($handle$print_doc);
printer_start_page($handle);

printer_set_option($handlePRINTER_MODETEXT);
printer_set_option($handlePRINTER_TITLE"PHP Printing");
printer_set_option($handlePRINTER_ORIENTATIONPRINTER_ORIENTATION_PORTRAIT);
printer_set_option($handlePRINTER_PAPER_FORMATPRINTER_FORMAT_A4);
printer_set_option($handlePRINTER_COPIES,1);
printer_set_option($handlePRINTER_RESOLUTION_Y,200);
printer_set_option($handlePRINTER_RESOLUTION_X,200);
printer_set_option($handlePRINTER_TEXT_COLOR000000);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

echo 
"Trying to print $print_doc using $printer_name - id: $handle"
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 23-10-2003, 03:50 PM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Have you configured the php printer libraries in php.ini?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 23-10-2003, 05:10 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
aya... sudah la supian. kalau dok edjust takdonye den nak post kan cini ha. network punyo printer pun den x leh print. kengkawan yang tau tuh silo2 lah bantu den ni.
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 23-10-2003, 05:20 PM
Ben-davis's Avatar
Senior Webmaster
 
Join Date: Jan 2002
Location: SoObHanG JhaYa
Posts: 501
Rep Power: 94
Ben-davis is on a distinguished road
Send a message via ICQ to Ben-davis Send a message via Yahoo to Ben-davis
p/s: hymns... ko ON dak printer ko? muehehehhe....
__________________
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" style="border:1px #393F31 solid;color:#393F31;font:10px Verdana;font-weight:bold;" >
<option value="0" style="background: #9CC8FE" selected>*SELECT-LINKS</option>
<option value="http://www.gengturbo.org/" style="background: #FF0000">GENGTURBO</option>
<option value="http://www.phixelgrafix.com/" target="new" style="background: #C6D607">PHIXELGRAFIX</option>
<option value="http://dailydigital.phixelgrafix.com/" style="background: #FCBC45">OLD-BLOG</option>
<option value="http://www.mesrahosting.net/" style="background: #FF99CC">WEBHOSTING</option>
</select>
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 23-10-2003, 07:05 PM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Hahahaha...

Anyway, I managed to re-write the code and managed to get it working...

PHP Code:
<?php
$handle 
printer_open("HPL7");
$file file("wohoo.txt");

foreach(
$file as $line){ 
    if (isset(
$print_text)) {
        
$print_text $print_text $line;
    } else {
        
$print_text $line;
    }
}

printer_write($handle$print_text);
printer_close($handle);

echo 
$print_text;
?>
printer_open("HPL7"); defines the printer. 'HPL7' is the name of the printer in COntrol Panel > Printers & Faxes. Use the name EXACTLY as shown in that panel. If you want to use the default printer (windows default), you can use printer_open()

If you want to use a network printer, subsitute printer_open("HPL7"); with:
printer_open("\\\\DOMAIN_NAME\\Printer_Name");
(Note the extra slashes)

In this code, it attempts to print a text file (wohoo.txt) which is in the same directory as this script.

If you want to use a full physical path, make sure you use double back slashes (\\) or forward slashes (/).

This is just a simple example I made... you can modify it to accommodate your print options: printer_set_option

If you have any questions, feel free to dump them here...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 23-10-2003, 07:13 PM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Oh yeah.. i forgot to say... My script will only work with text files (ASCII files)

BTW, the way you tried to do it, using printer_start_doc($handle, $print_doc); where $print_doc is the file location wont work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 23-10-2003, 11:58 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
why won't work ha? aiya! susah ma itu macham... itu mau print excel or work tatak woleh wooo.... anybody can print doc using this function?
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 24-10-2003, 08:29 AM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
hymns, what are you trying to do? Maybe if you explain it more, we can think of alternatives/workarounds.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 29-10-2003, 11:12 AM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
ahak!~ aku nak print excel doc sebab aku buat report guna query sql then convert ke excel format utk create graf. so aku nak bila org tengok keuntungan diorang dari graf terus leh print graf tuh... hek hek
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 29-10-2003, 11:55 AM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Ic...

Just a question, will the app run on a LAN or on the Web? If it's running on the web and you want remote users to be able to print documents using this fucntions, it wont work. Documents will only be printed on printers which are connected to the server (local or networked).

An alternative is to use GD to generate a graph, then use the brower's print function to print the document.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 29-10-2003, 06:51 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
ahaks... lupa plak aku nak bagi tau kek ko ni... aku nak print as local jerk...
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 02-11-2003, 03:42 PM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Well... can't help you there hymns.. your best stab would probably still be to use GD to generate a graph then use your browser's print function.

However, I believe that it can be done - the way you want it too. Just needs the patience... but I wouldn't waste my time doing or reinventing something insignificant that can already be done a simpler way...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 02-11-2003, 05:11 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 769
Rep Power: 101
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
orait tak kisah la... anyway time kasehhhhhhhhhhhhh!! kalau ade kengkawan lain nak tolong solve silakan!
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display XML document with several different element in table form by XSLT? danielwst Website Design 8 05-04-2007 05:16 AM
The hottest web,print and interactive design company in Malaysia ! riveron Websites Review and Suggestion 0 10-08-2005 12:36 PM
print function ardella Website Programming 2 13-05-2004 12:50 AM
php : perbezaan print & echo progmania Website Programming 2 18-08-2003 09:14 AM
print kasih Website Programming 3 16-11-2002 11:25 AM


All times are GMT +8. The time now is 10:41 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61