Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    printing in PHP: cutting off bottom of page

    using ePDF printer, a color printer, and a grayscale printer - 3 different entities, all capture and print my webpage where the bottom line might be cut off in the middle of the line [height-wise.] is there a way in PHP to prevent this? the page is simply table rows and data, and text areas. i am using either IE's File>Print, or javascript button which runs window.print();. greatly needed by HR to print and not cut off the information. Thanks for your time!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    How about a slightly smaller font size, or line-height (space between lines).
    These are controlled by the CSS (style sheet).
    But we don't have enough information anyhow to know what you mean by PHP.
    What script, and how is the data rendered?

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    printing html page rendered via PHP - cutting off bottom

    mlseim - thx much for your reply - by PHP i mean the scripting language - the page is rendered via PHP and "echo" statements scripting the table rows and data with mySQL fields in the cells. now, if i simply shrink the fonts and sizes of things, when it comes time to overflow the page won't it still cut if off like it is doing?

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    We of course have no way to see your code ...
    So I'll just say that right before <table>, add
    something similar to this:

    echo"
    <style>
    table, td{
    font-family:arial;
    font-size:12px;
    line-height:15px;
    color:#000;
    }
    </style>
    ";

  • Users who have thanked mlseim for this post:

    dcparham (08-26-2009)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks again for reply - so to give code, i have a css style controlling the main part of the page, including your "line-height:15px;" - the css:

    Code:
    .textArea1
    {
    width:720px; 
    height:100px; 
    font-family:Arial;
    font-size:10pt;
    text-align:left;
    background-color:rgb(233,222,255);
    overflow:visible;
    line-height:15px;
    }
    the thing is, depending on how much info was stuffed into the textareas, that causes the page to grow in a way so as to cause a sentence to be chopped in the middle of its height. in other words, it does not always happen because the pages might be created with differing amounts of info in each textarea causing the bottom section runoff to occur at different times. NOW - do you suppose your suggestion includes the wisdom of the "line-height" being such a multiple so as to cause an "even break" at the bottom of the page? perhaps line-height:15px always allows overflow to occur at the bottom or top of a sentence, whereas say 13 or 14 might allow overflow to cause a cutoff?

    it just so happens that the value 15 works better, but i am afraid it is simply due to the content added to the textareas; more or less content [provided page is large enough to overflow at the bottom] would then cause a mid-sentence cutoff at some point. however, 15, 13, 17 works whereas 14,16,18 do not. by the time you use 19 [ironically an odd #], things work fine since so much space in between sentences avoids cutoff.

    *to your credit*, 15 seems like a magic # for now, and i really feel better now - THANK YOU! [however, my original question is "is there not a setting allowing overflow to not cut off a sentence, just as with notepad, wordpad, msWord, or other 'legitimate' apps?" well, for *now* crisis averted, and you certainly get credit for that! QUESTION - how do i give people official credit/points, etc for answering question[s]?

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Have you put any thought into creating a PHP script JUST for outputting the
    data for a printout? I mean, instead of doing a "screenprint" of your data, you
    have an actual separate PHP script that outputs the data in a unique format,
    just for a printout.

    Would it be possible for us to see your web page? The page where you want to
    print it out on your printer? Maybe if I can see that, I might be able to come up
    with a better solution.

    If it's something that should not be public, PM me with the link.

  • #7
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hi mlseim - you have been very helpful and i thank you for your input! i thought a little about creating a file for output, but did not want to tackle that just yet. i wonder could i count the number of "echo" commands issued in a script, then when it reaches a critical #, trigger a CSS page break similar to what this link shows: http://www.boutell.com/newfaq/creating/pagebreak.html. as it says, "<p style="page-break-before: always"> This will force a page break when printing, before the start of this particular <p> element." so, put the style in each text area, then whenever the output line count reaches its threshhold, it will go to another page. then reset the counter. just an idea.

    the page is part of an intranet and i do not know how to show you the page. when it displays it is simply something like a title header with person's name, position, hire date, etc, then the question as stated when they filled out the evaluation on the previous page, then the textarea with the information they input on the previous page; then another question, a textarea; another question, a textarea, etc. at the bottom of page it shows [sometimes] a textarea with say 4 lines... then it stops... then next page it shows line#3, etc. but sometimes it also shows say line 4 or whatever, then half of line 5 cut down the middle across the page, then the next page shows the bottom of line 5.

    if you really want an image of the page i will create a pdf and email it to you. what is your idea of the output file?

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Here's the way I see it ...

    You have something that comes out on a web page.
    You then want to print that page.

    The print function is part of Windows, and not a PHP script.
    So, once the form is showing on your screen, you're past the
    point of inserting any breaks.

    The key might be to control the form as it's displayed on your screen.
    That's where PHP can come in, but your form is made on an editor?
    Which is why a PHP script should build the form from a database.

    So in summary, I think you're "putting the cart ahead of the horse".

    If we knew more about how the form is created?

  • #9
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    in some cases, the page is built simply by receiving $_POST or $_SESSION vars; in other cases it reads from a mySQL table and puts a "blob" field variable into a textarea with style attribute visibility:yes [expands the textarea as needed.] in one case the page displays one user's input and other vars, then another user's input and the same vars, etc, etc. so the page displays output, then starts over and adds to it by displaying the very same info from another user, then another and another, depending on how many people gave input to a person for their performance evaluation. very simple actually - i should display code, so OK - forgive my brevity - i am trying to learn Zend's ldap user authentication and up against a deadline [hint, hint, are you familiar?] - here is code for a page built from post and/or session vars [will begin after having recvd vars from previous page, and written to db table; then i read the vars[to output what has been in fact already written to the db]:

    Code:
    ...
    $resultSet1 = $dbObj->query($sql1);
    $sql2 = "SELECT * from $tableName where staffName='".$staffName."';";
    
    $resultSet2 = $dbObj->query($sql2);
    ////////////////////////////////////////////////////
    $i=0;
    echo "<table border='0' class='tableMain'>";
    echo "<tr bgcolor='orange'><td colspan='2'><span style='width:500px; text-align:center; font-family:Arial;font-size:10pt;font-weight:normal;'>
    Thank you, <b>".$staffFirst."</b> for submitting your <b>Admin</b> Self Evaluation!</td>
    <td style='width:140px; text-align:right;' ><input type='button' name='print' class='printButton' value='PRINT' onClick='printPage();'>
    <input type='button' name='goBack' class='goBackButton' value='go back' onClick='goBack();' /></span></td></tr>";
    echo "</table>";
    echo "<br />";
    //echo $staffName.": before while mysql_fetch_array";
    
    while($row = mysql_fetch_array($resultSet2, MYSQL_ASSOC))
    
    {
    
    
    $i++;
    if($i%2)
    {
    $rowColor='rgb(200,200,222)';
    }
    else
    {
    $rowColor='rgb(244,244,244)';
    }
    /////##################
    $staffname=$row['staffname'];
    $office=$officeLocation;
    $q1List=$row['q1List'];
    $q2New=$row['q2New'];
    $q3Goals=$row['q3Goals'];
    $q4Support=$row['q4Support'];
    $q5Actions=$row['q5Actions'];
    $q6Factors=$row['q6Factors'];
    $q7Activities=$row['q7Activities'];
    $q8Skills=$row['q8Skills'];
    $q9Mentoring=$row['q9Mentoring'];
    $rating=$row['rating'];
    $additionalComments=$row['additionalComments'];
    /////##################
    
    $nextYear=date('Y')+1;
    echo "<table border='0' class='tableStaff'>";
    echo "<tr style='background-color:white;'><td width='50%'>Staff Name: ".$staffName."(".ucFirst($office)."): ".$position."</td>
    <td width='50%' style='text-align:center;'><font size='1'>Date/Time of Eval: ".$timeStamp."</font></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>1. List your most significant accomplisments or contributions since last year. 
    How do these achievements align with the goals/objectives outlined in your last review?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q1List."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>2. Please describe any <b>new</b> responsibilities you have taken on this year.
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q2New."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>3. What goals have you set for yourself for ".$nextYear."?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q3Goals."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>4. What can management do to support the goals that you have set for yourself?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q4Support."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>5. What actions have you taken to improve teamwork within your POD, Dept., or the Firm?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q5Actions."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>6. To which of the following factors would you attribute your professional development since last year: offsite seminars/classes, onsite training, peer training, management coaching or mentoring, on-the-job experience, better exposure to challenging projects, other - please describe.
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q6Factors."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>7. What professional development activities would you like to see made available to you?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q7Activities."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>8. What professional skills/abilities do you have that could be better utilized?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q8Skills."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2' style='text-align:left;'>9. Has the mentoring/supervision you have received been effective? Do you have suggestions for improvement?
    </td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$q9Mentoring."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='2'>Additional Comments</td></tr>";
    echo "<tr><td colspan='3'><textarea class='textArea1' readonly='yes' cols=30 rows=15 wrap=soft>".$additionalComments."</textarea></td></tr>";
    
    echo "<tr class='trStyleAdmin'><td colspan='3' style='text-align:left;'>7. How would you rate your overall performance on a scale of 1 to 5? ---> Answer: ".$rating."</textarea></td></tr>";
    
    echo "<tr><td colspan='3' style='background-color:rgb(176,0,38);font-family:Arial;font-size:8pt;color:white;'>
    *Note:  Company Performance Review Disclaimer Here.
    <br /><br /><center><i><b><u>Remember - Salaries are Confidential</u></b></i></center>
    </td></tr>";
    
    echo "</table>";
    }
    echo "<hr style='width:3px;'>";
    }//if $result==0 END
    sure, it's lots of lines of code, but conceptually very basic.
    the other page is built showing each user's input, then repeats if other users gave input to a person for their performance eval...:
    Code:
    for($i=0;$i<$index;$i++)//do for as many Evaluators that exist for this one person
    
    {// for evalAlternate BEGIN 
    //### here is the var to write to db
    $evaluatorList = $evaluatorList."; ".$arrayEvaluator[$i];
    //echo $arrayEvaluator[$i]."; ";
    $evaluatorCount++;
    }
    $evaluatorCount--;
    $evaluatorList = ltrim($evaluatorList,";");
    echo "<table border='0' class='tableStaff'>";
    
    echo "<div class='div1EvalFinalDraftButtons_Alternate'><input type='button' class='evalFinalDraftButtonPrint_Alternate' value='Print Page' onclick='printPage();'>
    <input type='button' value='go back' class='evalFinalDraftButtonBack_Alternate' onclick='goBack();'></div>";
    
    echo "<tr><td>(Alternate): ".$staffName."(".$office.")</td><td>Date of Hire: &nbsp;&nbsp;&nbsp;&nbsp;<label>".$dateOfHire."</label></td></tr>";
    echo "<tr><td>Position:";
    echo "<select name='position' class='selectPosition'>";
    echo "<option id='default' value='default' selected>Select Staff's position:</option>";
    echo "<option id='accounting' value='Accounting'>Accounting</option>";
    echo "<option id='attorney' value='Attorney'>Attorney</option>";
    echo "<option id='billing' value='Billing'>Billing</option>";
    echo "<option id='legalAssistant' value='Legal Assistant'>Legal Assistant</option>";
    echo "<option id='officeAdmin' value='Office Administration'>Office Administration</option>";
    echo "<option id='paralegal' value='Paralegal'>Paralegal</option>";
    echo "<option id='receptionist' value='Receptionist'>Receptionist</option>";
    echo "<option id='secretary' value='Secretary'>Secretary</option>";
    echo "<option id='serviceTech' value='Service Technician'>Service Technician</option>";
    echo "<option id='wordPro' value='Word Processing'>Word Processing</option>";
    echo "</select>";
    echo "</td>";
    echo "<td>Date of Review: <input type='text' name='dateOfReview' id='dateOfReview' /></td></tr>";
    echo "<tr><td>Input Providers:</td>";
    echo "<td>";
    echo $evaluatorList."(".$evaluatorCount.")";
    echo "</td></tr>";
    
    echo "<tr><td colspan='10'>Strengths:</td></tr>";
    echo "<tr><td colspan='10'><textarea name='txtAreaStrengths' class='textArea1' cols=40 rows=15 wrap=soft></textarea></td></tr>";
    
    echo "<tr><td colspan='10'>Areas to Improve:</td></tr>";
    echo "<tr><td colspan='10'><textarea name='txtAreaImprove' class='textArea1' cols=40 rows=15 wrap=soft></textarea></td></tr>";
    
    echo "<tr><td colspan='10'>Goals:</td></tr>";
    echo "<tr><td colspan='10'><textarea name='txtAreaGoals' class='textArea1' cols=40 rows=15 wrap=soft></textarea></td></tr>";
    
    echo "<tr class='trStyle3'><td colspan='3'>Comments</td></tr>";
    echo "<tr><td colspan='10'><textarea name='txtAlFinalComments' class='textArea1' cols=40 rows=15 wrap=soft>";
    for($i=0;$i<$index;$i++)
    	{//for $i BEGIN
    	$txtVar1 = "txt1Al".str_replace(', ', '_', $staffName)."0".str_replace(', ', '_', $arrayEvaluator[$i]);
    	$txtVar1 = "(".$arrayEvaluator[$i]."): ".$_POST[$txtVar1]."\n";
    	echo $txtVar1."\n";
    	//echo $i."\n";
    	}	
    echo "</textarea></td></tr>";
    
    echo "<tr><td colspan='10'>Items for Discussion:</td></tr>";
    echo "<tr><td colspan='10'><textarea name='txtAreaItems' class='textArea1' cols=40 rows=15 wrap=soft></textarea></td></tr>";
    
    
    //echo "staff/evaluator: ".$staffName."/".$evaluatorName."<br />";
    //no need to build textarea name[s] using staffName concatenated with evaluatorName
    //in this Final Draft, there is only 1 textarea, with hardcoded unique names
    //pass those to the write process.
    
    echo "</table><br />";
    mlseim-again, thx very much for your time and expertise!

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    At the beginning of your script, let's start a line counter,
    $line_count=0;

    Also, a spot in CSS for the class:
    <STYLE TYPE="text/css">
    p.breakhere {page-break-after: always}
    </STYLE>


    Each time you encounter another output tag, add more ...
    For each textbox, checkbox, radio button, add 2:
    $line_count=$line_count+2;
    if($line_count>60){
    echo"<p class='breakhere'></p>";
    $line_count=0;
    }


    Now, you'll need to first determine how many average characters (example, 80)
    there are on each <textarea> line. Then, add depending on the length of the string:
    $len=strlen($q9Mentoring);
    $line_count=$line_count+($len/80);
    if($line_count>60){
    echo"<p class='breakhere'></p>";
    $line_count=0;
    }


    Any time the $line_count gets over 60 lines (or whatever),
    it will do the print break and then reset.

    This involves adding and checking for each form element, but
    it's the only way I can think of.

  • Users who have thanked mlseim for this post:

    dcparham (09-15-2009)

  • #11
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    that's probably exactly what i will plan to do, mlseim - thank you for your time and effort in this! i had abandoned it for now since i am working on php-ldap-authentication problem which has become much more critical. i will likely implement the linecount-pagebreak system however, because printing will be an issue. thank you again! you have pressed in with a solution that took creativity, not only technical knowledge [then again, welcome to programming] you really are most helpful!

  • #12
    New Coder
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    mlseim - what about this: when outputting database variables to the screen, how would those lines be counted? so when outputting textareas, they might be "100px" tall, which I will have to estimate to be a certain # of lines, as well as each textarea gets displayed inside of it, a database field. thanks again for your help before; this just occurred to me recently.


  •  

    Posting Permissions

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