Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Text string to multiple lines

  1. #11
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Okay Daniel the code you provided:

    PHP Code:
    $str explode('|',$str);
    for (
    $i=0;$i<count($str);$i++) {
    echo 
    $str[$i]."\n";

    Works great now is there a way to do using

    PHP Code:
    printer_draw_text($handle$specship13600); 
    So that each line that your code generates goes into its own printer_draw_text()
    Ryan
    Sevierville, TN

  2. #12
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Okay i got my last question answered my self. so here is what my final code looks like. Provided for learning purpose.

    PHP Code:
    <?php

    $int_y_pos 
    3600;
    $int_y_step_small 100;

    $str_value "Feel free to use the regular|expression we made above on your own site to validate|email addresses, or modify it for your own purposes.";

    $handle printer_open("Brother HL-5150D"); 

    printer_set_option($handlePRINTER_MODEtext);
    printer_set_option($handlePRINTER_TEXT_ALIGNPRINTER_TA_LEFT);

    printer_start_doc($handle"Invoice");
    printer_start_page($handle);

    $str explode('|',$str_value);
    for (
    $i=0;$i<count($str);$i++) {

    $int_y_pos += $int_y_step_small;

    printer_draw_text($handle$str[$i], 1$int_y_pos);

    }

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

    ?>
    This code allows you to take a string and break it up to multiple lines for PHP's print function. In my case (not shown above) every where the code picks up a </p> (generated by TinyMCE) it breaks it into a new printer_draw_text() function for printing straight to a printer (Windows Only).
    Ryan
    Sevierville, TN

  3. #13
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Cool!

    -magicyte

Bookmarks

Posting Permissions

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