Community Documentation

Advanced Example

Last updated April 17, 2008. Created by jredding on April 17, 2008.
Log in to edit this page.

This example is to be used with the attached sample JPEG.

Step 1

Create a new badge and set the following
page orientation = Portrait
Page Style = Image (Width/Height are ignored when page style is set to image)

Step 2

Upload the attached sample JPEG to the newly created badge

Step 3

Copy/paste the following code into the PHP section of the badge.

//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 exactly one year from date printed.
$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
PDF-IDcard-sample_badge.jpg152.47 KB

Comments

$account->profile_firstname don't work.

These codes don't work in the drupal 6x.beta1 version of the module
even when i applied profile_load_profile($account) function

$pdf->Cell(10,40,strtoupper($account->profile_firstname),0,0,"left",0,0);

Can u figure out why?

About this page

Drupal version
Drupal 5.x
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.