Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter jakeashley

    (@jakeashley)

    @barrykooij

    No problem. I figured it out.

    For others interested:

    use setasign\Fpdi\Fpdi;
    
    add_filter( 'dlm_file_path', 'auto_custom_flyer' );
    function auto_custom_flyer($this) {
    
    	require('FPDF/fpdf.php');
    	require_once('FPDI/src/autoload.php');
    	
    	$current_user = wp_get_current_user();
    	$user_headshot = get_avatar_url( wp_get_current_user() );
    	// Initiate FPDI library
    	$pdf = new Fpdi();
    	// Add a PDF page
    	$pdf->AddPage('P', 'Letter');
    	// Set the source file of that PDF page
    	$pdf->setSourceFile($this);
    	// Import file
    	$tplIdx = $pdf->importPage(1);
    	// Use the imported file and place it at position 0,0 with a width of 215.9 (US Letter 215.9mm x 279.4mm)
    	$pdf->useTemplate($tplIdx, 0, 0, 215.9);
    	
    	// Now add headshot and information/custom fields on top of the imported PDF file
    	$pdf->Line(9.525, 209, 206.375, 209);
    	$pdf->SetFont('Helvetica');
    	$pdf->SetTextColor(0, 0, 0);
    	$pdf->SetFontSize(9);
    	$pdf->SetXY(41.935, 213.763);
    	$pdf->MultiCell(61.253,4,"$current_user->display_name \nLoan Officer \nNMLS #123456 \n\n555-555-5555 \n$current_user->user_email");
    	$pdf->SetFont('Helvetica');
    	$pdf->SetTextColor(0, 0, 0);
    	$pdf->SetFontSize(7);
    	$pdf->SetXY(9.525, 250);
    	$pdf->MultiCell(0,3,"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
    	$pdf->Image($user_headshot,9.525,213.763,28,0,'JPEG');
    	
    	
    	
    	$pdf->Output();
    }
Viewing 1 replies (of 1 total)