Rectangle 27 3

As mentioned in the comments above this is possible by using a stream ("data url") to hand over the image data to the fpdf library without writing physical files to disk:

<?php
// load the 'fpdf' extension
require('fpdf.php');

// just for demonstration purpose, the OP gets the content from a database instead
$h_img = fopen('img.jpg', "rb");
$img = fread($h_img, filesize('img.jpg'));
fclose($h_img);

// prepare a base64 encoded "data url"
$pic = 'data://text/plain;base64,' . base64_encode($img);
// extract dimensions from image
$info = getimagesize($pic);

// create a simple pdf document to prove this is very well possible: 
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello Image!');
$pdf->Image($pic, 10, 30, $info[0], $info[1], 'jpg');
$pdf->Output();

If this is a good advice is another question, this is merely meant to prove that this is possible...

Interesting proposal but I'm not quite sure I understand your example; why use fopen() at all? Could OP simply use $pdf->Image('data://text/plain;base64,'.base64_encode($row['photoData']), 10, 30, 40, 40, 'jpg'); and avoid the calls to fopen(), fread(), and fclose()? If so then this answer is better than mine because the only disk access would be the DB read operation for photoData. I am personally not familiar with this part 'data://text/plain;base64,' so maybe that is the source of my confusion.

@MonkeyZeus Of course the fopen() fread() fclose() sequence is not required at all for the OP. That is why I added that remark to it clearly stating that fact. The code is meant as a primitive example to demonstrate the point here. Code examples should be complete in themselves if possible, so that they can be tried with as little implicit requirements as possible. Glad I could be of help and shed some light here. Have fun!

An interesting debate and another good answer. One issue however is the sizing of the image. In your example you have 40 x 40. I realise this could be altered but could it be dynamic ie to handle portrait vs landscape?

@RichardGriffiths That is a completely separate question about fpdf I'd say. In my eyes what you ask does make that much sense: pdf is a format to place elements in a very precise and distinct manner, quite unlike html. There is a workaroud however I remember using in tcpdf: it is easy in php to ask the dimensions of an image, you can use those values in the ->Image() call. Again you don't really need a physical file for that, you can use the same url scheme as shown in this answer here. Oh, and for flexible and convenient layouting: github.com/arkascha/php-urithmetic ;-)

php - Image from database into PDF using FPDF - Stack Overflow

php pdf fpdf
Rectangle 27 3

As mentioned in the comments above this is possible by using a stream ("data url") to hand over the image data to the fpdf library without writing physical files to disk:

<?php
// load the 'fpdf' extension
require('fpdf.php');

// just for demonstration purpose, the OP gets the content from a database instead
$h_img = fopen('img.jpg', "rb");
$img = fread($h_img, filesize('img.jpg'));
fclose($h_img);

// prepare a base64 encoded "data url"
$pic = 'data://text/plain;base64,' . base64_encode($img);
// extract dimensions from image
$info = getimagesize($pic);

// create a simple pdf document to prove this is very well possible: 
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello Image!');
$pdf->Image($pic, 10, 30, $info[0], $info[1], 'jpg');
$pdf->Output();

If this is a good advice is another question, this is merely meant to prove that this is possible...

Interesting proposal but I'm not quite sure I understand your example; why use fopen() at all? Could OP simply use $pdf->Image('data://text/plain;base64,'.base64_encode($row['photoData']), 10, 30, 40, 40, 'jpg'); and avoid the calls to fopen(), fread(), and fclose()? If so then this answer is better than mine because the only disk access would be the DB read operation for photoData. I am personally not familiar with this part 'data://text/plain;base64,' so maybe that is the source of my confusion.

@MonkeyZeus Of course the fopen() fread() fclose() sequence is not required at all for the OP. That is why I added that remark to it clearly stating that fact. The code is meant as a primitive example to demonstrate the point here. Code examples should be complete in themselves if possible, so that they can be tried with as little implicit requirements as possible. Glad I could be of help and shed some light here. Have fun!

An interesting debate and another good answer. One issue however is the sizing of the image. In your example you have 40 x 40. I realise this could be altered but could it be dynamic ie to handle portrait vs landscape?

@RichardGriffiths That is a completely separate question about fpdf I'd say. In my eyes what you ask does make that much sense: pdf is a format to place elements in a very precise and distinct manner, quite unlike html. There is a workaroud however I remember using in tcpdf: it is easy in php to ask the dimensions of an image, you can use those values in the ->Image() call. Again you don't really need a physical file for that, you can use the same url scheme as shown in this answer here. Oh, and for flexible and convenient layouting: github.com/arkascha/php-urithmetic ;-)

php - Image from database into PDF using FPDF - Stack Overflow

php pdf fpdf
Rectangle 27 7

As I am using the same for exactly the same task...

Thank you very much for your response. Guess it's time for trying out FPDI Library.

Edit existing PDF file using FPDF - Stack Overflow

pdf fpdf
Rectangle 27 7

As I am using the same for exactly the same task...

Thank you very much for your response. Guess it's time for trying out FPDI Library.

Edit existing PDF file using FPDF - Stack Overflow

pdf fpdf
Rectangle 27 4

This error simply means that FPDF is using a function call that is deprecated and outdated. This is shown because your PHP displays errors and warnings and deprecation notes. You should try turning off errors before generating the PDF or writing @ before function calls (like here) when using FPDF.

fpdf - How to insert Image in pdf using PHP (Generating a PDF)? - Stac...

php fpdf
Rectangle 27 1

You can use Dhek graphical tool to design a template in JSON format, defining areas (bounds, name, ...) you want to add later on existing PDF (using FPDF and dynamic data). See doc at https://github.com/cchantep/dhek/blob/master/README.md#php-integration .

Using fpdf to modify existing pdf in php - Stack Overflow

php pdf fpdf
Rectangle 27 1

Not overly familiar with fPDF. It looks OK for quick, simple stuff. Have you tried using R&OS ezPDF Creator instead - not sure what state of development/maintenance it's in these days but I think it may give you more detailed control for the kind of output you want. I've used it for years for bespoke PDF output from PHP. Just checked and it looks like it's still being maintained - see:

php - How to create pdf like a example using fpdf - Stack Overflow

php pdf fpdf
Rectangle 27 3

// once there are no errors, as soon as the customer hits the submit button, it needs to send an email to the staff with the customer information
        $msg = "Name: " .$_POST['name'] . "\n"
            ."Email: " .$_POST['email'] . "\n"
            ."Phone: " .$_POST['telephone'] . "\n"
            ."Number Of Guests: " .$_POST['numberOfGuests'] . "\n"
            ."Date Of Reunion: " .$_POST['date'];
        $staffEmail = "staffemail";

        mail($staffEmail, "You have a new customer", $msg); // using the mail php function to send the email. mail(to, subject line, message)

        //once the customer submits his/her information, he/she will receive a thank you message attach with a pdf file.
        // creating a pdf file
        $pdf_filename = tempnam(sys_get_temp_dir(), "pdf");
        $pdf=new FPDF();
        $pdf->AddPage();
        $pdf->SetFont("Arial", "B", 16);
        $pdf->Cell(40, 10, "Title");
        $pdf->Ln();
        $pdf->SetFont("Arial", "", 12);
        $pdf->Cell(15, 10, "Name:");
        $pdf->SetFont("Arial", "I", 12);
        $pdf->Cell(15, 10, $_POST['name']);
        $pdf->Ln();
        $pdf->SetFont("Arial", "", 12);
        $pdf->Cell(15, 10, "Email:");
        $pdf->SetFont("Arial", "I", 12);
        $pdf->Cell(15, 10, $_POST['email']);
        $pdf->Ln();
        $pdf->SetFont("Arial", "", 12);
        $pdf->Cell(15, 10, "Phone:");
        $pdf->SetFont("Arial", "I", 12);
        $pdf->Cell(15, 10, $_POST['telephone']);
        $pdf->Ln();
        $pdf->SetFont("Arial", "", 12);
        $pdf->Cell(40, 10, "Number of Guests:");
        $pdf->SetFont("Arial", "I", 12);
        $pdf->Cell(40, 10, $_POST['numberOfGuests']);
        $pdf->Ln();
        $pdf->SetFont("Arial", "", 12);
        $pdf->Cell(40, 10, "Date Of Reunion:");
        $pdf->SetFont("Arial", "I", 12);
        $pdf->Cell(40, 10, $_POST['date']);
        // if file doesn't exists or if it is writable, create and save the file to a specific place 
        if(!file_exists($pdf_filename) || is_writable($pdf_filename)){
            $pdf->Output($pdf_filename, "F");
        } else { 
            exit("Path Not Writable");
        }

        // using the phpmailer class
        // create a new instance called $mail and use its properties and methods.
        $mail = new PHPMailer();
        $staffEmail = "staffemail";
        $mail->From = $staffEmail;
        $mail->FromName = "name";
        $mail->AddAddress($_POST['email']);
        $mail->AddReplyTo($staffEmail, "name");

        $mail->AddAttachment($pdf_filename);
        $mail->Subject = "PDF file attachment";

        $mail->Body = "message!";

        // if mail cannot be sent, diplay error message
        //if(!$mail->Send()){
            //echo "<div id=\"mailerrors\">Message could not be sent</div>";
            //echo "<div id=\"mailerrors\">Mailer Error: " . $mail->ErrorInfo . "</div>";
        //} else { // else...if mail is sent, diplay sent message
            //echo "<div id=\"mailerrors\">Message sent</div>";
        //}

        // delete the temp file
        unlink($pdf_filename);
    }
}

This is a late comment, but you probably should use tempnam to generate a unique file name so you do not risk having a problem with two customers hitting the script at once.

fpdf - Sending an email with a PDF Files attachment using PHP - Stack ...

php fpdf
Rectangle 27 2

I used this method to save google charts as an image by using base64 url to save in some folder from server side finally use in fpdf as an image from folder.

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">

    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawVisualization);

    function drawVisualization() {
    // Some raw data (not necessarily accurate)
    var data = google.visualization.arrayToDataTable([
    ['', ''],
    ['Numerical', 4],
    ['Verbal', 6],
    ['Mechanical', 4],  
    ['Reasoning', 5],  
    ['Spatial', 9]
    ]);

    var options = {
    title : '',
    vAxis: {title: "", viewWindowMode:'explicit',
          viewWindow:{
            max:12,
            min:0
          }},
    hAxis: {title: ""},
    seriesType: "bars",
    series: {5: {type: "line"}}
    };

    var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
    chart.draw(data, options);

    var app1=(chart.getImageURI());
        $.post("appt1.php",{postapp: app1},
        function(){});
    }
</script>
<div id="chart_div" style="display: none;"></div>


<!-- On the Server side  do this to store image appt1.php -->

$data =$_POST['postapp'];
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);

file_put_contents('exam_images/'."1".'.png', $data);

Not a bad solution, though I have to be able to generate them on the server side, which I cannot do with this solution

I finished up my project using the above method of generating reports. may be you are missing something :(

javascript - Using Google Charts API Generated Graphic in FPDF - Stack...

javascript php google-visualization fpdf
Rectangle 27 2

Correct me if I am wrong, but as far as i know FPDF is only able to use (include) image files. So what you could do is generate that graph with image headers and than include the link to that graph in FPDF (works fine when including things generated in php and adding image headers, but can be tricky with converting JS generated graphic, could need some hacks). Another solution (if possible) try using wkhtmltopdf. It generates PDF from html pages (again not sure if that will work with JS generated graphics).

javascript - Using Google Charts API Generated Graphic in FPDF - Stack...

javascript php google-visualization fpdf
Rectangle 27 3

I dont think Multicell is the solution for this.Problems in using multicell.

  • overlaps with next row

More over we cant able predict how much height a cell may goes? eg: if first cell text length is 50 and the second text lenght is 100 then its height differs so we cant able to create as a table row.

Even the above answer helps to solve only the break of line but not overlap problem.

Here i came with a new solution for this.a new function vcell() uses only cell in it to make the expected output successfully.

<?php
require('fpdf.php');
class ConductPDF extends FPDF {
function vcell($c_width,$c_height,$x_axis,$text){
$w_w=$c_height/3;
$w_w_1=$w_w+2;
$w_w1=$w_w+$w_w+$w_w+3;
$len=strlen($text);// check the length of the cell and splits the text into 7 character each and saves in a array 
if($len>7){
$w_text=str_split($text,7);
$this->SetX($x_axis);
$this->Cell($c_width,$w_w_1,$w_text[0],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$w_w1,$w_text[1],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$c_height,'','LTRB',0,'L',0);
}
else{
    $this->SetX($x_axis);
    $this->Cell($c_width,$c_height,$text,'LTRB',0,'L',0);}
    }
 }
$pdf = new ConductPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',16);
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;// cell width 
$c_height=6;// cell height
$text="aim success ";// content 
$pdf->vcell($c_width,$c_height,$x_axis,'Hi1');// pass all values inside the cell 
$x_axis=$pdf->getx();// now get current pdf x axis value
$pdf->vcell($c_width,$c_height,$x_axis,'Hi2');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi3');
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=12;
$text="aim success ";
$pdf->vcell($c_width,$c_height,$x_axis,'Hi4');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi5(xtra)');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi5');
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=12;
$text="All the best";
$pdf->vcell($c_width,$c_height,$x_axis,'Hai');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'VICKY');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,$text);
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=6;
$text="Good";
$pdf->vcell($c_width,$c_height,$x_axis,'Hai');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'vignesh');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,$text);
$pdf->Output();
?>
function vcell($c_width,$c_height,$x_axis,$text){
$w_w=$c_height/3;
$w_w_1=$w_w+2;
$w_w1=$w_w+$w_w+$w_w+3;
// $w_w2=$w_w+$w_w+$w_w+$w_w+3;// for 3 rows wrap
$len=strlen($text);// check the length of the cell and splits the text into 7 character each and saves in a array 
if($len>7){
$w_text=str_split($text,7);// splits the text into length of 7 and saves in a array since we need wrap cell of two cell we took $w_text[0], $w_text[1] alone.
// if we need wrap cell of 3 row then we can go for    $w_text[0],$w_text[1],$w_text[2]
$this->SetX($x_axis);
$this->Cell($c_width,$w_w_1,$w_text[0],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$w_w1,$w_text[1],'','','');
//$this->SetX($x_axis);
// $this->Cell($c_width,$w_w2,$w_text[2],'','','');// for 3 rows wrap but increase the $c_height it is very important.
$this->SetX($x_axis);
$this->Cell($c_width,$c_height,'','LTRB',0,'L',0);
}
else{
    $this->SetX($x_axis);
    $this->Cell($c_width,$c_height,$text,'LTRB',0,'L',0);}
    }

@JeremyCanfield: it a height . $w_w=$c_height/3; example:if you want to wrap a word with 3 line.and the cell height is 9 so 9/3=3. first w_w line will be echo in height 3 and next line is echoed in height 6 and next line will be in height 9.

suppose You don't know whether cell is enough or not, how exactly are you proposing that if it needed to divide automatically..? For the first raw you hard coded height as 6 and for the 2nd raw you hard coded height as 12. What if this needed to decide automatically?

@ChanakaSuranga : I have given a idea, find a function which creates height automatically based on character count. then your problem solved :). Find automatically and pass it.

pdf - Wrap Text in Fpdf in Php - Stack Overflow

php pdf fpdf word-wrap
Rectangle 27 3

I dont think Multicell is the solution for this.Problems in using multicell.

  • overlaps with next row

More over we cant able predict how much height a cell may goes? eg: if first cell text length is 50 and the second text lenght is 100 then its height differs so we cant able to create as a table row.

Even the above answer helps to solve only the break of line but not overlap problem.

Here i came with a new solution for this.a new function vcell() uses only cell in it to make the expected output successfully.

<?php
require('fpdf.php');
class ConductPDF extends FPDF {
function vcell($c_width,$c_height,$x_axis,$text){
$w_w=$c_height/3;
$w_w_1=$w_w+2;
$w_w1=$w_w+$w_w+$w_w+3;
$len=strlen($text);// check the length of the cell and splits the text into 7 character each and saves in a array 
if($len>7){
$w_text=str_split($text,7);
$this->SetX($x_axis);
$this->Cell($c_width,$w_w_1,$w_text[0],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$w_w1,$w_text[1],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$c_height,'','LTRB',0,'L',0);
}
else{
    $this->SetX($x_axis);
    $this->Cell($c_width,$c_height,$text,'LTRB',0,'L',0);}
    }
 }
$pdf = new ConductPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',16);
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;// cell width 
$c_height=6;// cell height
$text="aim success ";// content 
$pdf->vcell($c_width,$c_height,$x_axis,'Hi1');// pass all values inside the cell 
$x_axis=$pdf->getx();// now get current pdf x axis value
$pdf->vcell($c_width,$c_height,$x_axis,'Hi2');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi3');
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=12;
$text="aim success ";
$pdf->vcell($c_width,$c_height,$x_axis,'Hi4');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi5(xtra)');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'Hi5');
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=12;
$text="All the best";
$pdf->vcell($c_width,$c_height,$x_axis,'Hai');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'VICKY');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,$text);
$pdf->Ln();
$x_axis=$pdf->getx();
$c_width=20;
$c_height=6;
$text="Good";
$pdf->vcell($c_width,$c_height,$x_axis,'Hai');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,'vignesh');
$x_axis=$pdf->getx();
$pdf->vcell($c_width,$c_height,$x_axis,$text);
$pdf->Output();
?>
function vcell($c_width,$c_height,$x_axis,$text){
$w_w=$c_height/3;
$w_w_1=$w_w+2;
$w_w1=$w_w+$w_w+$w_w+3;
// $w_w2=$w_w+$w_w+$w_w+$w_w+3;// for 3 rows wrap
$len=strlen($text);// check the length of the cell and splits the text into 7 character each and saves in a array 
if($len>7){
$w_text=str_split($text,7);// splits the text into length of 7 and saves in a array since we need wrap cell of two cell we took $w_text[0], $w_text[1] alone.
// if we need wrap cell of 3 row then we can go for    $w_text[0],$w_text[1],$w_text[2]
$this->SetX($x_axis);
$this->Cell($c_width,$w_w_1,$w_text[0],'','','');
$this->SetX($x_axis);
$this->Cell($c_width,$w_w1,$w_text[1],'','','');
//$this->SetX($x_axis);
// $this->Cell($c_width,$w_w2,$w_text[2],'','','');// for 3 rows wrap but increase the $c_height it is very important.
$this->SetX($x_axis);
$this->Cell($c_width,$c_height,'','LTRB',0,'L',0);
}
else{
    $this->SetX($x_axis);
    $this->Cell($c_width,$c_height,$text,'LTRB',0,'L',0);}
    }

@JeremyCanfield: it a height . $w_w=$c_height/3; example:if you want to wrap a word with 3 line.and the cell height is 9 so 9/3=3. first w_w line will be echo in height 3 and next line is echoed in height 6 and next line will be in height 9.

suppose You don't know whether cell is enough or not, how exactly are you proposing that if it needed to divide automatically..? For the first raw you hard coded height as 6 and for the 2nd raw you hard coded height as 12. What if this needed to decide automatically?

@ChanakaSuranga : I have given a idea, find a function which creates height automatically based on character count. then your problem solved :). Find automatically and pass it.

pdf - Wrap Text in Fpdf in Php - Stack Overflow

php pdf fpdf word-wrap
Rectangle 27 1

A zero in the cell syntax represents no boarder. it works the same for a multicell.

<?php

include_once 'scripts/init.php'; //Connect to the database
require 'fpdf/fpdf.php';
require 'fpdf/rotation.php';   //import fpdf and the watermark class

$aptid = $_SESSION['apt'];  //The applicant ID

//Class to create the water mark
class PDF extends PDF_Rotate
{
function Header()
{
    //Put the watermark
    $this->SetFont('Arial','B',50);
    $this->SetTextColor(255,192,203);
    $this->RotatedText(35,190,'FOR VERIFICATION ONLY',45);
}

function RotatedText($x, $y, $txt, $angle)
{
    //Text rotated around its origin
    $this->Rotate($angle,$x,$y);
    $this->Text($x,$y,$txt);
    $this->Rotate(0);
}
}

$pdf=new PDF(); //create an instance of the fpdf class
$pdf->AddPage(); //create the pdf page

//Retrieve the qualification holder details from the database
$query = "SELECT a.QhFullName, a.QhDOB, a.Qualification, a.IssuingBody, a.CompletionDate, a.EntryRequirements, a.CountryEligibility, a.ProgrammeRequirements, a.MinStudyDuration, a.CountryLevel, a.OrgField, a.SubFramework, a.NQFLevel, a.Credits, a.ClosestQualification
                    FROM Evaluation a
                    INNER JOIN Apn b ON a.ApnID = b.AptID
                    WHERE b.AptID LIKE $aptid";


    $stmt = sqlsrv_query( $conn, $query);

    $record = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC);
    $text = 'Born: ';
    $text0 = '                                                                       ';
    $text1 = '                                     ';

    //heading
    $pdf->SetFont("Arial","B",10);
    $pdf->Cell(0,10,$record['QhFullName'].$text0.$text.$record['QhDOB'],1,1,"L");
    //body of the pdf
    $pdf->ln();



//Display the qualification holders details on a pdf table using Cells
$pdf->SetFont("Arial","",06);
$pdf->Cell(80,5,'Qualification(1):',0,0,'L',0);
$pdf->Cell(80,5,$record['Qualification'],0,1,'L',0);
$pdf->Cell(80,5,'Awarding body/Institution:',0,0,'L',0);
$pdf->Cell(80,5,$record['IssuingBody'],0,1,'L',0);
$pdf->Cell(80,5,'Date of completion / award:',0,0,'L',0);
$pdf->Cell(80,5,$record['CompletionDate'],0,1,'L',0);
$pdf->Cell(80,5,'Purpose of the qualification:',0,0,'L',0);
$pdf->Cell(80,5,$record['CountryEligibility'],0,1,'L',0);
$pdf->Cell(80,5,'Minimum entry requirement:',0,0,'L',0);
$pdf->MultiCell( 80, 5,$record['EntryRequirements'], 0);
$pdf->Cell(80,5,'Minimum duration of study:',0,0,'L',0);
$pdf->Cell(80,5,$record['MinStudyDuration'],0,1,'L',0);
$pdf->Cell(80,5,'Requirements for the award:',0,0,'L',0);
$pdf->Cell(80,5,$record['ProgrammeRequirements'],0,1,'L',0);
$pdf->Cell(80,5,'Requirements for the award:',0,0,'L',0);
$pdf->Cell(80,5,$record['CountryLevel'],0,1,'L',0);

$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,9,'RECOGNITION DECISION',0,1,'L',0);

$pdf->Cell(80,5,'Qualification(s) describe above:',0,0,'L',0);
$pdf->Cell(80,5,'Closest comparable South African qualification / qualification type',0,1,'L',0);

$pdf->Cell(80,5,'(1):',0,0,'C',0);
$pdf->Cell(80,5,$record['ClosestQualification'],0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Organising Field:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['OrgField'],0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Sub-framework location:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['SubFramework'],0,1,'L',0);

$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'NQF Level(see overleaf):',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,substr($record['NQFLevel'], -1),0,1,'L',0);

$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Credits:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['Credits'],0,1,'L',0);


$pdf->Output();  //Output data to the PDF
?>

mysql - A borderless table using fpdf in PHP - Stack Overflow

php mysql fpdf
Rectangle 27 1

<form action="printpdf.php" method="post" id="print">
    <input type="text" size="25" name="first_name" />
    <input type="submit" />
</form>
<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(40, 10, $_POST['first_name']);
$pdf->Output();
?>

Note that this is taken almost directly from the FPDF tutorial.

If you're doing a lot with PDFs, you may consider using DOMPDF.

Thanks for your help.It solved the problem.I'm pretty much learning the way FPDF works from scratch.Once again thanks.

php - Outputting text fields into PDF file using FPDF - Stack Overflow

php fpdf
Rectangle 27 18

Use GetY to get the current position, subtract it from the height of your document. If that is less than 6x (you have 6 rows) your multicell height, then force a page break by using AddPage.

I know you fixed this, but for the benefit of anyone else, this should give a broad idea.

<?php
$p = new FPDF();
$p->AddPage();
$p->SetFont('Arial','B',16);
$p->SetAutoPageBreak(false);
$height_of_cell = 60; // mm
$page_height = 286.93; // mm (portrait letter)
$bottom_margin = 0; // mm
  for($i=0;$i<=100;$i++) :
    $block=floor($i/6);
    $space_left=$page_height-($p->GetY()+$bottom_margin); // space left on page
      if ($i/6==floor($i/6) && $height_of_cell > $space_left) {
        $p->AddPage(); // page break
      }
    $p->Cell(100,10,'This is a text line - Group '.$block,'B',2);
  endfor;
$p->Output();
?>

Hi, I modified the code like that, but it does nothing. Do you see an error somewhere?

Because it was useful to me note that for A4 $page_height = 297;

SetAutoPageBreak(boolean auto , float margin) fx helped me.The second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.

Yes absolutely @Ravs, that would be the typical application. The OP here wanted to make sure all 6 rows would fit, just using the autopagebreak would break his tables up if 1-5 rows would fit on the page, which is why he needed a more elaborate solution.

php - fpdf page break issue - Stack Overflow

php pdf pdf-generation fpdf
Rectangle 27 18

Use GetY to get the current position, subtract it from the height of your document. If that is less than 6x (you have 6 rows) your multicell height, then force a page break by using AddPage.

I know you fixed this, but for the benefit of anyone else, this should give a broad idea.

<?php
$p = new FPDF();
$p->AddPage();
$p->SetFont('Arial','B',16);
$p->SetAutoPageBreak(false);
$height_of_cell = 60; // mm
$page_height = 286.93; // mm (portrait letter)
$bottom_margin = 0; // mm
  for($i=0;$i<=100;$i++) :
    $block=floor($i/6);
    $space_left=$page_height-($p->GetY()+$bottom_margin); // space left on page
      if ($i/6==floor($i/6) && $height_of_cell > $space_left) {
        $p->AddPage(); // page break
      }
    $p->Cell(100,10,'This is a text line - Group '.$block,'B',2);
  endfor;
$p->Output();
?>

Hi, I modified the code like that, but it does nothing. Do you see an error somewhere?

Because it was useful to me note that for A4 $page_height = 297;

SetAutoPageBreak(boolean auto , float margin) fx helped me.The second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm.

Yes absolutely @Ravs, that would be the typical application. The OP here wanted to make sure all 6 rows would fit, just using the autopagebreak would break his tables up if 1-5 rows would fit on the page, which is why he needed a more elaborate solution.

php - fpdf page break issue - Stack Overflow

php pdf pdf-generation fpdf
Rectangle 27 1

I am using PHP, FPDF to generate a pdf from an FDF file and then insert a qrcode graphic into the pdf as well. I kept running into trouble because my empty pdf has form fields built in and inserting a graphic with other programs erased my form fields. I finally figured it out. Hope this helps someone else who is struggling with the same.

I work for funeral home if any of the var names throw you off and this code isn't polished its been cut and pasted from tons of different sources ;)

for($count=0;$count<$doc_list_length;$count++){

    //create FDF file
    $id = rand(11111,99999);
    $filename = $populated_pdf_path . $casenumber.$doc_list[$count].".fdf";    
    $file = fopen($filename,"w");
    $filecontents = "%FDF-1.2". PHP_EOL;
    $filecontents .= "%" . PHP_EOL;
    $filecontents .= "1 0 obj" . PHP_EOL;
    $filecontents .= "<<" .PHP_EOL;
    $filecontents .= "/FDF << /Fields [ ";
    $filecontents .= "<</T(name)/V($name)>>";
    $filecontents .= "] " . PHP_EOL;
    $filecontents .= "/F (empty_pdf/$doc_list[$count].pdf) ";
    $filecontents .= "/ID [ <$id>" . PHP_EOL;
    $filecontents .= "] >> " . PHP_EOL;
    $filecontents .= ">> ". PHP_EOL;
    $filecontents .= "endobj" . PHP_EOL;
    $filecontents .= "trailer" . PHP_EOL;
    $filecontents .= "<<" . PHP_EOL;
    $filecontents .= "/Root 1 0 R" . PHP_EOL . PHP_EOL;
    $filecontents .= ">>" . PHP_EOL;
    $filecontents .= "%%EOF";
    fwrite($file, $filecontents);
    fclose($file);

    //insert image on this document only
    //generate qrcode
    if($doc_list[$count] == "checklist"){

        $qrCodeFileName = $cemetery."qrcode.png";
        if(!file_exists($populated_pdf_path.$qrCodeFileName)){
            include('include/phpqrcode/qrlib.php');  
            $codeContents = "http://www.asuperduperwebaddress.com"; 
            QRcode::png($codeContents, $populated_pdf_path.$qrCodeFileName);
        }

        if(!file_exists($populated_pdf_path.$cemetery."qrcode.pdf")){
            //make pdf with image
            require_once('include/fpdf.php');
            $image = $populated_pdf_path.$qrCodeFileName;
            $pdf = new FPDF();
            $pdf->AddPage();
            $pdf->Image($image, 183, 250, 25, 25, 'PNG' );
            $pdf->Output( $populated_pdf_path.$cemetery."qrcode.pdf");
        }

        //setup file paths for pdf output
        $tempFile = $populated_pdf_path . $casenumber.$doc_list[$count]."temp.pdf";
        $pdfExampleFile = $populated_pdf_path . $casenumber.$doc_list[$count].".pdf"; 
        $pdfFile = $empty_pdf_path . $doc_list[$count] . ".pdf";
        if($doc_list[$count] == "checklist")
        $fdfFile = $filename; 
        $fdfTemplateFile = $filename;

        //fill pdf
        $command = "pdftk $pdfFile fill_form $fdfTemplateFile output $tempFile 2> fill_form.log";
        passthru($command);

        //stamp pdf with qrcode
        $command = "pdftk " . $tempFile . " stamp " . $populated_pdf_path.$cemetery . "qrcode.pdf output " . $pdfExampleFile; 
        passthru($command);
    }
    else{
        //setup file paths for pdf output
        $pdfExampleFile = $populated_pdf_path . $casenumber.$doc_list[$count].".pdf"; 
        $pdfFile = $empty_pdf_path . $doc_list[$count] . ".pdf";
        if($doc_list[$count] == "checklist")
        $fdfFile = $filename; 
        $fdfTemplateFile = $filename;

        //fill pdf
        $command = "pdftk $pdfFile fill_form $fdfTemplateFile output $pdfExampleFile 2> fill_form.log";
        passthru($command);
    }

}

Thanks. One change I had to make, a dest parameter is needed for the $pdf->Output call. I used: $pdf->Output("F", $filename);

Insert images files in existing PDF file using PHP - Stack Overflow

php pdf fpdf fpdi
Rectangle 27 1

I am using PHP, FPDF to generate a pdf from an FDF file and then insert a qrcode graphic into the pdf as well. I kept running into trouble because my empty pdf has form fields built in and inserting a graphic with other programs erased my form fields. I finally figured it out. Hope this helps someone else who is struggling with the same.

I work for funeral home if any of the var names throw you off and this code isn't polished its been cut and pasted from tons of different sources ;)

for($count=0;$count<$doc_list_length;$count++){

    //create FDF file
    $id = rand(11111,99999);
    $filename = $populated_pdf_path . $casenumber.$doc_list[$count].".fdf";    
    $file = fopen($filename,"w");
    $filecontents = "%FDF-1.2". PHP_EOL;
    $filecontents .= "%" . PHP_EOL;
    $filecontents .= "1 0 obj" . PHP_EOL;
    $filecontents .= "<<" .PHP_EOL;
    $filecontents .= "/FDF << /Fields [ ";
    $filecontents .= "<</T(name)/V($name)>>";
    $filecontents .= "] " . PHP_EOL;
    $filecontents .= "/F (empty_pdf/$doc_list[$count].pdf) ";
    $filecontents .= "/ID [ <$id>" . PHP_EOL;
    $filecontents .= "] >> " . PHP_EOL;
    $filecontents .= ">> ". PHP_EOL;
    $filecontents .= "endobj" . PHP_EOL;
    $filecontents .= "trailer" . PHP_EOL;
    $filecontents .= "<<" . PHP_EOL;
    $filecontents .= "/Root 1 0 R" . PHP_EOL . PHP_EOL;
    $filecontents .= ">>" . PHP_EOL;
    $filecontents .= "%%EOF";
    fwrite($file, $filecontents);
    fclose($file);

    //insert image on this document only
    //generate qrcode
    if($doc_list[$count] == "checklist"){

        $qrCodeFileName = $cemetery."qrcode.png";
        if(!file_exists($populated_pdf_path.$qrCodeFileName)){
            include('include/phpqrcode/qrlib.php');  
            $codeContents = "http://www.asuperduperwebaddress.com"; 
            QRcode::png($codeContents, $populated_pdf_path.$qrCodeFileName);
        }

        if(!file_exists($populated_pdf_path.$cemetery."qrcode.pdf")){
            //make pdf with image
            require_once('include/fpdf.php');
            $image = $populated_pdf_path.$qrCodeFileName;
            $pdf = new FPDF();
            $pdf->AddPage();
            $pdf->Image($image, 183, 250, 25, 25, 'PNG' );
            $pdf->Output( $populated_pdf_path.$cemetery."qrcode.pdf");
        }

        //setup file paths for pdf output
        $tempFile = $populated_pdf_path . $casenumber.$doc_list[$count]."temp.pdf";
        $pdfExampleFile = $populated_pdf_path . $casenumber.$doc_list[$count].".pdf"; 
        $pdfFile = $empty_pdf_path . $doc_list[$count] . ".pdf";
        if($doc_list[$count] == "checklist")
        $fdfFile = $filename; 
        $fdfTemplateFile = $filename;

        //fill pdf
        $command = "pdftk $pdfFile fill_form $fdfTemplateFile output $tempFile 2> fill_form.log";
        passthru($command);

        //stamp pdf with qrcode
        $command = "pdftk " . $tempFile . " stamp " . $populated_pdf_path.$cemetery . "qrcode.pdf output " . $pdfExampleFile; 
        passthru($command);
    }
    else{
        //setup file paths for pdf output
        $pdfExampleFile = $populated_pdf_path . $casenumber.$doc_list[$count].".pdf"; 
        $pdfFile = $empty_pdf_path . $doc_list[$count] . ".pdf";
        if($doc_list[$count] == "checklist")
        $fdfFile = $filename; 
        $fdfTemplateFile = $filename;

        //fill pdf
        $command = "pdftk $pdfFile fill_form $fdfTemplateFile output $pdfExampleFile 2> fill_form.log";
        passthru($command);
    }

}

Thanks. One change I had to make, a dest parameter is needed for the $pdf->Output call. I used: $pdf->Output("F", $filename);

Insert images files in existing PDF file using PHP - Stack Overflow

php pdf fpdf fpdi
Rectangle 27 1

Since using FPDF, you certainly have some PHP code looking like this.

output()
<td>
    <input id='$idd' type='button' value='View PDF'class='btn btn-primary' onclick='viewPDF(this.id)' target='_blank' >
</td>
<div id="pdfResult"></div>

<script>
function viewPDF(id){  
    $.ajax({  url: "viewCrf.php",
        data: {'idd' : id},
        type: "POST",
        success: function (data) {
            $("#pdfResult").html(data);
        }
    });
}
</script>

Still not showing anything. I edited my post and added an image of what the alert(data) is returning.

Check the Dest parameter of output(). It is I by default... It looks like you specified S... as for "string".

I didn't put anything inside the Output(). Yet it still returning the above picture.

header("Content-type: application/PDF");

Anyway, I found the answer :). I just used GET METHOD and change the button into an href.

javascript - Opening the PDF file onclick of a button with AJAX - Stac...

javascript php jquery ajax pdf
Rectangle 27 3

As Helle said, FPDF is a really neat tool for generating PDFs from PHP. Although using FPDF you'll have to dig into its manual, as it doesn't convert HTML into PDFs. From my experience though, FPDF is rather straightforward to use and you should not have too much trouble with it.

i tried this for several time, but i not get any luck yet, it seem hard code to me.

print to pdf with php? - Stack Overflow

php pdf printing