Php PDF yapma

PHP ile PDF oluşturmak için genellikle TCPDF, FPDF, veya mpdf gibi kütüphaneler kullanılır. İşte basit bir örnek:

  1. TCPDF kullanarak PDF oluşturma:

require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 16); $pdf->Cell(40, 10, 'Merhaba, Dünya!'); $pdf->Output('example.pdf', 'D');

  1. FPDF kullanarak PDF oluşturma:

require('fpdf/fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 16); $pdf->Cell(40, 10, 'Merhaba, Dünya!'); $pdf->Output('example.pdf', 'D');

  1. mpdf kullanarak PDF oluşturma:

require_once __DIR__ . '/vendor/autoload.php'; $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML('<h1>Merhaba, Dünya!</h1>'); $mpdf->Output('example.pdf', 'D');

Bu örnekler, temel bir PDF oluşturmanın nasıl yapılabileceğini gösterir. İlgili kütüphaneleri projenize dahil etmeyi ve gereksinimleri belirtmeyi unutmayın.

Yorum gönder

This site uses Akismet to reduce spam. Learn how your comment data is processed.