phpzend-frameworkfpdftcpdfpdflib

How to make business card with fpdf or tcpdf or others? When i have a jpg background and text overlap requires?


I have a jpg image for the business card layout with dimensions: 9,8 cm/5,9 cm. I have to put it as background layout and on top of this layout i have to print name/address/telephone number email etc. And print it/save it as pdf for later use.

But problem is i cant make it work with FPDF or TCPDF. Any idea how can i prepare this? with FPDF or TCPDF?


Solution

  • Using TCPDF you can position elements absolutely as it were, so you could do something like

    $pdf = new TCPDF('L', 'mm', 'A4'); //Or whatever your required settings are
    
    //Basic setup
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    
    $pdf->AddPage();
    
    $pdf->Image('src', x, y); //Where x and y are the offset (probably 0, 0)
    $pdf->writeHTMLCell(w, h, x, y, 'html') //Again where x and y are offset
    
    $pdf->Output('filename.pdf', 'D'); //To force download
    

    The TCPDF online documentation isn't great, but the examples help a lot http://www.tcpdf.org/examples.php