Jump to content

Recommended Posts

Hello.

 

I need help getting a page to print correctly with php.

 

I have a php script that displays the current invoices from a small shop on to the screen but, when I send to to print by pressing ctrl-p it prints the page with a border around the whole page. Also, if I only one to print one invoice, it prints but, again prints with the border around the page. These invoices are 8 1/2 by 5 1/2 (half of page). I'm trying to print them with an Epson lx 300 printer and I'm not getting the desire output. I don' t know if is the printer which I doubt, I've printed it on different printer it same result.

 

How can I get a page printed with php? or any other way?

 

Please help. Part of the script below.

 

Thanks in advanced for your help.

 

echo "<style><!-- .l { float: left; }  .r { float: right; }//--></style>";

echo "<table bgcolor='#ffffff' width='100%' align='center' border=0><tr><td>"; // used to make bg white

echo "<table bgcolor='#ffffff' width='100%' align='center' border=0>" .

    "<tr><td align='center'><strong>" . COMPANY_NAME . "</strong></td></tr>" .

    "<tr><td align='center'>" . COMPANY_ADDRESS . "</td></tr>" .

    "<tr><td align='center'>" . COMPANY_PHONE . "</td></tr>" .

    "</table><br>";

echo "<table bgcolor='#ffffff'  width='100%'>" .

    " <tr><td><!-- Client information --> ".

    "    <table border=0> " .

    "      <tr><td>" . $cust_row["customer_id"] . "</td></tr>" .

    "      <tr><td>" . $cust_row['customer_fname'] . " " . $cust_row['customer_lname'] . "</td></tr>" .

    "      <tr><td>" . $cust_row['customer_address1'] . "</td></tr>" .

    "      <tr><td>" . $cust_row['customer_address2'] . "</td></tr>" .

    "      <tr><td>" . $cust_row['customer_city'] . "</td></tr>" .

    "    </table>" .

    "</td><!-- Client information ends -->" .

    "<td valign=middle align=center><table  bgcolor='#ffffff' cellpadding='6' class='topBotBorder'><tr><td>FACTURA</td></tr></table></td>" .

    "<td valign=top><!-- Invoice information -->" .

    " <table  bgcolor='#ffffff' cellpadding=2 class='r'>" .

    "  <tr><td>No. Factura</td><td>:</td><td>" . $inv_row['inv_id'] . "</td></tr>".

    "  <tr><td>Fecha</td><td>:</td><td>" . $inv_date . "</td></tr>";

  while( $dev_row = mysql_fetch_array( $dev_result ) ){

    echo "  <tr><td>MAC</td><td>:</td><td>" . getMacDisplay( $dev_row['eq_mac_address'] ) . "</td></tr>";

  }

echo " </table>" .

    "</td></tr>" .

    "</table><br>" .

    "<table  bgcolor='#ffffff' width='100%'>" .

    "<tr align='center'><td class='invoice'>Balance Pendiente</td><td class='invoice'>Total del Mes</td><td class='invoice'>Total por Pagar</td></tr>" .

    "<tr align=center><td>$ " . $inv_row['inv_prior_bal'] . "</td><td>$ " . $inv_row['inv_amount'] . "</td><td width=30%>$ " . $inv_row['inv_cur_bal'] . "</td></tr>" .

    "</table><br><br>" .

    "<table bgcolor='#ffffff' class='topBorder' width='100%' align='center'>" .

    "<tr align=center><td>Fecha Limite de Pago $due_date</td></tr>" .

    "</table><br>";

 

echo "<table  bgcolor='#ffffff' width=100%><tr><td>" . INVOICE_MESSAGE . "</td></tr></table>" .

    "<br><br><table  bgcolor='#ffffff' width=100%><tr><td>" . $inv_row['inv_timestamp'] . " - $counter" . "</td><td class='topBorder' align='center'>   Firma del Cliente   </td></tr>" .

    "</table>";

   

echo "</td></tr></table>";

Link to comment
https://forums.phpfreaks.com/topic/155578-help-printing-a-page/
Share on other sites

Actually it's a browser or HTML error. PHP has nothing to do with print.

 

You can post the output of your php script (right-click to display the source of the page) in a [ code][/code] tag it will be easier to read and see where the error in your html come from.

 

You should really learn how to use the <table> html tag only for tabular data and how CSS work. It will be a lot easier to read, fix problem, upgrade or use another CSS sheet when printing.

 

You can try this at the top of your page :

 

<?php

echo '<style type="text/css">
@media print {
* { 
border:0;
}
}
</style>';

...
?>

 

It will remove all border from all html element when you print.

Link to comment
https://forums.phpfreaks.com/topic/155578-help-printing-a-page/#findComment-818779
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.