williamt74 Posted June 10, 2013 Share Posted June 10, 2013 I am working on some test code to figure out how to control print layout if I need to print info from a db in a specific format. What I am trying to do is pull data and print it on business cards. I have the system pulling the data and inserting it in to the card layout. The problem I am running in to is how to advance it to the next "cell" and get the page to line up correctly. What I have tried is a for loop where it limits the output to 10 card per page and 2 cards per row. This works if I print just 10 cards. If I print more then 10 it seems to duplicate the data and after about page 5 the alignment/layout is messed up. echo "<table>"; for ($i=0;$i<10;$i++) { echo"<tr>"; for ($ii=0;$ii<2;$ii++) { for ($iii=0;$iii<2;$iii++) { echo "<td>"; echo"<div style='height:2in;width:3.5in;'> $id, $Dept<br> $type $name<br> $sdate - $edate </div>"; echo"</td>"; } echo"</tr>"; } } echo "</table>"; echo "<p style='page-break-before: always'>"; I am sure there is a better way to do this and any suggestions or advice is appreciated, Thanks Quote Link to comment https://forums.phpfreaks.com/topic/279008-business-card-layout-print/ Share on other sites More sharing options...
Barand Posted June 10, 2013 Share Posted June 10, 2013 Output each card into a <div> with float:left style and desired width and height. Easier than table cells. Quote Link to comment https://forums.phpfreaks.com/topic/279008-business-card-layout-print/#findComment-1435213 Share on other sites More sharing options...
rwhite35 Posted June 10, 2013 Share Posted June 10, 2013 I would suggest looking at one of PHP's Image manipulation libraries. Personally, I prefer GD, but there are others. You would output one set of ten cards, then make that in to a JPEG, PNG or PDF template. You could then send the job to the printer and each print out would be identical. If each business card is a different individual's contact info, then you would run the first ten > print and then run the next ten and so on. Your program would have to keep track of the last card ran, but that would be the most effecient approach, at least in my mind. Quote Link to comment https://forums.phpfreaks.com/topic/279008-business-card-layout-print/#findComment-1435218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.