Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/279008-business-card-layout-print/
Share on other sites

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.

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.