Results 1 to 13 of 13

Thread: Print Document

  1. #1
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230

    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

  2. #2
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    Have you configured the php printer libraries in php.ini?

  3. #3
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230
    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

  4. #4
    Join Date
    Jan 2002
    Location
    SoObHanG JhaYa
    Posts
    501
    Rep Power
    223
    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>

  5. #5
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    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...

  6. #6
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    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.

  7. #7
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230
    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

  8. #8
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    hymns, what are you trying to do? Maybe if you explain it more, we can think of alternatives/workarounds.

  9. #9
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230
    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

  10. #10
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    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.

  11. #11
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230
    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

  12. #12
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    225
    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...

  13. #13
    Join Date
    Nov 2001
    Location
    Johor
    Posts
    772
    Rep Power
    230
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. magazine printing, print magazine, large print magazines, magazines printing
    By muqtada123 in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 16-10-2009, 02:29 AM
  2. document.write alternative for xhtml?
    By jim0n in forum Website Design
    Replies: 1
    Last Post: 10-08-2007, 11:27 PM
  3. Replies: 8
    Last Post: 05-04-2007, 05:16 AM
  4. print function
    By ardella in forum Website Programming
    Replies: 2
    Last Post: 13-05-2004, 12:50 AM
  5. print
    By kasih in forum Website Programming
    Replies: 3
    Last Post: 16-11-2002, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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