whyisjake

Jake Spurlock

Aug 26th, 2010
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. <?php
  2. require('fpdf/fpdf.php');
  3. require('functions.php');
  4.  
  5. // Set up the new PDF object
  6. $pdf = new FPDF();
  7.  
  8. // Set the text color to white.
  9. $pdf->SetTextColor(255,255,255);
  10.  
  11. // Remove page margins.
  12. $pdf->SetMargins(0, 0);
  13.  
  14. // Disable auto page breaks.
  15. $pdf->SetAutoPageBreak(0);
  16.  
  17. // Grab the attendee list
  18. $attendees = array(
  19.    array( 'first_name' => 'Jake', 'last_name' => 'Spurlock', 'email' => 'whyisjake@gmail.com', 'blog' => 'http://jakespurlock.com' ),
  20.    array( 'first_name' => 'Matt', 'last_name' => 'Reinbold', 'email' => 'matthew.reinbold@voxpopdesign.com', 'blog' => 'http://voxpopdesign.com' ),
  21.    array( 'first_name' => 'Joseph', 'last_name' => 'Scott', 'email' => 'joseph@automattic.com', 'blog' => 'http://josephscott.org' )
  22. );
  23.  
  24. // Set up badge counter
  25. $counter = 1;
  26.  
  27. // Loop through each attendee and create a badge for them
  28. for ( $i = 0; $i < count($attendees); $i++ ) {
  29.         // Grab the template file that will be used for the badge page layout
  30.         require('templates/avery74549.php');
  31.  
  32.         // Download and store the gravatar for use, FPDF does not support gravatar formatted image links
  33.         $grav_file_raw = 'images/temp/' . $attendees[$i]['first_name'] . '-' . rand();
  34.         $grav_data = get_file_by_curl( 'http://www.gravatar.com/avatar/' . md5($attendees[$i]['email']) . '?s=512&default=identicon', $grav_file_raw );
  35.  
  36.         // Check if the image is a png, if it is, convert it, otherwise add a JPG extension to the raw filename
  37.         if ( !$grav_file = pngtojpg($grav_file_raw) ) {
  38.             $grav_file_extension = get_image_extension($grav_file_raw);
  39.             $grav_file = $grav_file_raw . $grav_file_extension;
  40.             rename( $grav_file_raw, $grav_file );
  41.         }
  42.  
  43.         // Add the background image for the badge to the page
  44.         $pdf->image('images/back.jpg', $background_x, $background_y, 96, 61);
  45.         $pdf->image($grav_file, $avatar_x, $avatar_y, 21, 21);
  46.  
  47.         // Set the co-ordinates, font, and text for the first name
  48.         $pdf->SetXY($text_x, $text_y);
  49.         $pdf->SetFont('helvetica','b',33);
  50.         $pdf->MultiCell(86, 13,ucwords(stripslashes($attendees[$i]['first_name'])),0,'R');
  51.  
  52.         // Set the co-ordinates, font, and text for the last name
  53.         $pdf->SetXY($text_x, $text_y + 11);
  54.         $pdf->SetFont('helvetica','',16);
  55.         $pdf->MultiCell(86, 13,stripslashes(ucwords($attendees[$i]['last_name'])),0,'R');
  56.  
  57.         // Remove http:// from blog URL's and also remove ending slashes
  58.         $attendees[$i]['blog'] = str_replace('http://', '', $attendees[$i]['blog']);
  59.  
  60.         if ( $attendees[$i]['blog'][strlen($attendees[$i]['blog']) - 1] == '/' )
  61.             $attendees[$i]['blog'][strlen($attendees[$i]['blog']) - 1] = '';
  62.  
  63.         // Set the co-ordinates, font, and text for the blog url
  64.         $pdf->SetXY($text_x, $text_y + 17);
  65.         $pdf->SetFont('helvetica','',10);
  66.         $pdf->MultiCell(86, 13,$attendees[$i]['blog'],0,'R');
  67.  
  68.         $counter++;
  69. }
  70.  
  71. // Output the PDF file to the browser
  72. $pdf->Output();
  73.  
  74. ?>
Add Comment
Please, Sign In to add comment