简体   繁体   中英

how to use pdf library in php?

When i start it's showing this error

 <?php
     $p = PDF_new();
 ?>
Fatal error: Call to undefined function PDF_new() in D:\wamp\www\upload.php on line 2

I am using Wamp Server. I tried in XAMPP also. Is there any directives i have to enable to execute the code ?

i suggest to you tcpdf . it was good for me. some feature:

  • no external libraries are required for the basic functions;

  • all standard page formats, custom page formats, custom margins and units of measure;

  • UTF-8 Unicode and Right-To-Left
    languages;

I think http://www.fpdf.org/ is the best PDF library for PHP. Download latest version from http://www.fpdf.org . Put this library folder on your root server or in your project. Create on test file named test.php & put below code in file as below.

<?php
include("fpdf/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',36);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

It will create one pdf file with contents "Hello World!" in it. You are done..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM