PDF-IDCard updated.

Events happening in the community are now at Drupal community events on www.drupal.org.
jredding's picture

Just a quick note about the various projects that I've been working on. While I was still in the U.S I had a chance to make a stable release for the PDF-IDCard module. The module takes a jpeg or png file and overlays text on top of it. Eric and the guys at OpenFlows had done a similar custom job (which served as the base and inspiration for this module) and I took their work and made a Drupal module out of it. I attempted to make it "easier" to create this badges on a large scale.

The module uses the TCPDF object library and extends it to offer vertical printing. I think an awesome addition to the module would be to incorporate the mugshot module so that a piece of embedded flash code can take a picture of the user directly on the user's profile page. This way you could edit their profile, take their picture AND print out their badge all on a single page. (Imagine a web cam on a tripod next to a desk; it'd be cool and super easy to do). Alas I didn't have time to incorporate this feature.

When I was in California visiting Jay and Ryan I whipped up this PHP code for Denver Open Media to create their staff badges. It directly corresponds to the attached image (i.e. if you don't use this image the x,y coordinates are off.)

To recreate their badge on your site (as an example to creating your own).
First install the PDF-IDCard module and configure the path correctly for the TCPDF library.
Second create a PDF-IDCard template with the following options
--Upload the attached picture
--Page orientation "Portrait"
--Page Style "Image" (height/width don't matter as the page style set these automatically)

In the PHP code section copy and paste the following.

That's it! The PHP code area is full on PHP so you can do all kinds of things with it.

//Load the full user profile for this account
profile_load_profile($account);

//print horizontal first name
$pdf->SetFont('freemono', '', 60);
$pdf->setxy(52,178);
$pdf->SetTextColor(100,100,100);
$pdf->Cell(10,40,strtoupper($account->profile_firstname),0,0,"left",0,0);

//print horizontal last name
$pdf->SetFont('freemono', '', 65);
$pdf->setxy(52,192);
$pdf->SetTextColor(255,0,0);
$pdf->Cell(10,40,strtoupper($account->profile_lastname),0,0,"left",0,0);

//Print expirydate
$pdf->SetFont('freemono', 'b', 20);
$pdf->setxy(79,202);
$pdf->SetTextColor(0,0,0);
$expirydate = date('n/j/Y', mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1));
$pdf->Cell(10,40,$expirydate,0,0,"left",0,0);

//Print vertical firstname
$pdf->SetFont('freemono', '', 40);
$pdf->Rotate(-90, 270, 0);
$pdf->setxy(321,9);
$pdf->SetTextColor(100,100,100);
$pdf->Write(10,strtoupper($account->profile_firstname), NULL, 0);

//Print vertical lastname
$pdf->SetTextColor(240,0,0);
$pdf->SetFont('freemono', '', 45);
$pdf->Write(10,strtoupper($account->profile_lastname), NULL, 0);
AttachmentSize
DOM ID badge.jpg143.03 KB

Comments

a question

nirvale's picture

that's good, but i wish to print the user role in the idcard, i mean in my site i have a reader member and colaborator member, and that's the role, i can't print it in the id card

Community Media

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: