Generate PDF From FPDF PHP

here is my code i need to input my details how can i insert data from database values in heading and content..
<?php
session_start();
if(!isset($_SESSION['user_id'])) {
header("Location: index.php");
exit();
}

include ('../../includes/dbc.php');
$query="select * from contents where state='1' and (publish_down >= '".date('Y-m-d')."' and publish_up <= '".date('Y-m-d')."') and id='".$_GET['id']."'";
$dataset=mysql_query($query)or die(mysql_error());
$dsRow=mysql_fetch_array($dataset);
?>
<?
require('../fpdf.php');
class PDF extends FPDF
{
//Page header
function Header()
{
      //Logo
      $this->Image('logo.gif',10,8,20);
      //Arial bold 15
      $this->SetFont('Arial','B',15);
      //Move to the right
      $this->Cell(80);
      //Title
      $this->Cell(30,10,Put the title from database?'',0,0,'C');
      //Line break
      $this->Ln(20);
}

//Page footer
function Footer()
{
      //Position at 1.5 cm from bottom
      $this->SetY(-15);
      //Arial italic 8
      $this->SetFont('Arial','I',8);
      //Page number
      $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}

//Instanciation of inherited class
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->Cell(0,10,'Put the code from database?',0,1);
$pdf->Output();
?>
anilpotterAsked:
Who is Participating?
 
anilpotterAuthor Commented:
0
 
shobinsunCommented:
Hi,

just use the values from database in :

$pdf->Cell(0,10,$dsRow->value,0,1);

0
 
shobinsunCommented:
$pdf->Cell(0,10,$dsRow['value'],0,1);

Use this.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
InsoftserviceCommented:
hi,

<?php
      class InvoicePDF extends FPDF
      {
            var $arrContent;
   
     function print()
{
            $this->Cell(30,5,$this-> arrContent,1,0,'L');
}


       }


0
 
InsoftserviceCommented:
hi,

srry,

hi,

<?php
      class InvoicePDF extends FPDF
      {
            var $arrContent;
   
     function print()
{
            $this->Cell(30,5,$this-> arrContent,1,0,'L');
}

function set($arrContent)
{
 $this-> arrContent = $arrContent;
}

       }

I am providing you such complex because u can use this a general class for any part of ur any code

0
 
anilpotterAuthor Commented:
$pdf->Cell(0,10,$dsRow['value'],0,1); this code prints the text but my text goes out of scope
value contains html formatted output
like
<p>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam nibh. Nunc varius facilisis eros. Sed erat. In in velit <br />
      <br />
      quis arcu ornare laoreet. Curabitur adipiscing luctus massa. Integer ut purus ac augue commodo commodo. Nunc nec mi eu <br />
      <br />
      justo tempor consectetuer. Etiam vitae nisl. In dignissim lacus ut ante. Cras elit lectus, bibendum a, adipiscing <br />
      <br />
      vitae, commodo et, dui. Ut tincidunt tortor. Donec nonummy, enim in lacinia pulvinar, velit tellus scelerisque augue, <br />
      <br />
      ac posuere libero urna eget neque. Cras ipsum. Vestibulum pretium, lectus nec venenatis volutpat, purus lectus <br />
      <br />
      ultrices risus, a condimentum risus mi et quam. Pellentesque auctor fringilla neque. Duis eu massa ut lorem iaculis <br />
      <br />
      vestibulum. Maecenas facilisis elit sed justo. Quisque volutpat malesuada velit. <br />
      <br />
      Nunc at velit quis lectus nonummy eleifend. Curabitur eros. Aenean ligula dolor, gravida auctor, auctor et, suscipit <br />
      <br />
      in, erat. Sed malesuada, enim ut congue pharetra, massa elit convallis pede, ornare scelerisque libero neque ut neque. <br />
      <br />
      In at libero. Curabitur molestie. Sed vel neque. Proin et dolor ac ipsum elementum malesuada. Praesent id orci. Donec <br />
      <br />
      hendrerit. In hac habitasse platea dictumst. Aenean sit amet arcu a turpis posuere pretium. </p>
0
 
anilpotterAuthor Commented:
i have html formated output how can i manage these things
0
 
InsoftserviceCommented:
hi,

fpdf depends on cell .
So you have to do it cell wise and not like html. if u want to display such o/p use "r&os " for it.

for each line u have to use different code given above
0
 
InsoftserviceCommented:
hi,

$this->SetFont('Times','B',10);
                        $this->Cell(0,6,"ONunc at velit quis lectus nonummy eleifend. Curabitur eros. Aenean ligula dolor, gravida auctor, auctor et, suscipit  ",0,0,'L');
                        $this->Ln(5);
                        $this->Cell(0,6,"tIn at libero. Curabitur molestie. Sed vel neque. Proin et dolor ac ipsum elementum malesuada. Praesent id orci. Donec,",0,0,'L');
                        $this->Ln(5);
                        $this->Cell(0,6,"Curabitur molestie. Sed vel neque. Proin et dolor ac ipsum elementum malesuada. Praesent id orci. Donec .",0,0,'L');

nearly similar code
0
 
anilpotterAuthor Commented:
sorry i can't understand how to loop the text because the text is formated output like html tags.. li,ul,p
$html=$dsRow->fulltext;

$pdf->Cell(0,10,$html,0,1); how can i process...
0
 
InsoftserviceCommented:
hi,
 its very tedious job. if u have only html to be publish . i will suggest  "R&OS"
0
 
anilpotterAuthor Commented:
i use this script
http://www.fpdf.org/en/tutorial/tuto4.htm
i write the wholeout put in the txt file and this works fine except from tags please send me the link that convert this into html
this is the main code
$f=fopen($file,'r');
    $txt=fread($f,filesize($file));
    fclose($f);
    //Times 12
    $this->SetFont('Times','',12);
    //Output justified text
    $this->MultiCell(0,5,$txt);
    //Line break
    $this->Ln();
    //Mention in italics
    $this->SetFont('','I');
    $this->Cell(0,5,'(end of excerpt)');
but is there any way and tell me what is R&OS
0
 
anilpotterAuthor Commented:
http://www.ros.co.nz/pdf/

if i type </p>Hello</p> it gives me the same output
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.