Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('fpdf/fpdf.php');
- require('functions.php');
- // Set up the new PDF object
- $pdf = new FPDF();
- // Set the text color to white.
- $pdf->SetTextColor(255,255,255);
- // Remove page margins.
- $pdf->SetMargins(0, 0);
- // Disable auto page breaks.
- $pdf->SetAutoPageBreak(0);
- // Grab the attendee list
- $attendees = array(
- array( 'first_name' => 'Jake', 'last_name' => 'Spurlock', 'email' => 'whyisjake@gmail.com', 'blog' => 'http://jakespurlock.com' ),
- array( 'first_name' => 'Matt', 'last_name' => 'Reinbold', 'email' => 'matthew.reinbold@voxpopdesign.com', 'blog' => 'http://voxpopdesign.com' ),
- array( 'first_name' => 'Joseph', 'last_name' => 'Scott', 'email' => 'joseph@automattic.com', 'blog' => 'http://josephscott.org' )
- );
- // Set up badge counter
- $counter = 1;
- // Loop through each attendee and create a badge for them
- for ( $i = 0; $i < count($attendees); $i++ ) {
- // Grab the template file that will be used for the badge page layout
- require('templates/avery74549.php');
- // Download and store the gravatar for use, FPDF does not support gravatar formatted image links
- $grav_file_raw = 'images/temp/' . $attendees[$i]['first_name'] . '-' . rand();
- $grav_data = get_file_by_curl( 'http://www.gravatar.com/avatar/' . md5($attendees[$i]['email']) . '?s=512&default=identicon', $grav_file_raw );
- // Check if the image is a png, if it is, convert it, otherwise add a JPG extension to the raw filename
- if ( !$grav_file = pngtojpg($grav_file_raw) ) {
- $grav_file_extension = get_image_extension($grav_file_raw);
- $grav_file = $grav_file_raw . $grav_file_extension;
- rename( $grav_file_raw, $grav_file );
- }
- // Add the background image for the badge to the page
- $pdf->image('images/back.jpg', $background_x, $background_y, 96, 61);
- $pdf->image($grav_file, $avatar_x, $avatar_y, 21, 21);
- // Set the co-ordinates, font, and text for the first name
- $pdf->SetXY($text_x, $text_y);
- $pdf->SetFont('helvetica','b',33);
- $pdf->MultiCell(86, 13,ucwords(stripslashes($attendees[$i]['first_name'])),0,'R');
- // Set the co-ordinates, font, and text for the last name
- $pdf->SetXY($text_x, $text_y + 11);
- $pdf->SetFont('helvetica','',16);
- $pdf->MultiCell(86, 13,stripslashes(ucwords($attendees[$i]['last_name'])),0,'R');
- // Remove http:// from blog URL's and also remove ending slashes
- $attendees[$i]['blog'] = str_replace('http://', '', $attendees[$i]['blog']);
- if ( $attendees[$i]['blog'][strlen($attendees[$i]['blog']) - 1] == '/' )
- $attendees[$i]['blog'][strlen($attendees[$i]['blog']) - 1] = '';
- // Set the co-ordinates, font, and text for the blog url
- $pdf->SetXY($text_x, $text_y + 17);
- $pdf->SetFont('helvetica','',10);
- $pdf->MultiCell(86, 13,$attendees[$i]['blog'],0,'R');
- $counter++;
- }
- // Output the PDF file to the browser
- $pdf->Output();
- ?>
Add Comment
Please, Sign In to add comment