Jump to content


Photo

Creating 2 columns with text in pdf using PHP


  • Please log in to reply
No replies to this topic

#1 990wes

990wes

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 10 September 2013 - 02:44 AM

Hello guys,

 

I trying to create two columns with text in pdf using PHP. I hope you can help me.

 

Here is my PHP script.

 

 

<html>
<head>
 <title>internetprotocol</title>
</head>
<body>
 <h3>internetprotocol</h3>
<?php
require ('C:\xampp\php\pear\fpdf\fpdf.php');
   
$x = 50;
 $pdf = new FPDF('P', 'mm', 'A4');

   if(!empty($_POST['naam']) && !empty($_POST['emailadres']) && !empty($_POST['naamSchool']) && !empty($_POST['websiteSchool']) && !empty($_POST['adresSchool']) && !empty($_POST['karakters']) && !empty($_POST['plaats-postcode']) )
   {
    $x = 50;
    
    $pdf->SetFont('Times','', 8);
    $pdf->addPage('P', 'A4');
    $pdf->SetXY($x,50);
    
    $target_path = "logos/";
    $target_path = $target_path . basename( $_FILES['logoSchool']['name']);
    if(move_uploaded_file($_FILES['logoSchool']['tmp_name'], $target_path))
    {
     echo "The file ".  basename( $_FILES['logoSchool']['name']).
     " has been uploaded";
    }
    else
    {
     echo "There was an error uploading the file, please try again!";
    }
    
    $pdf->Image($target_path,10,6,30);

    $pdf->Cell(0, 1, '', 0, 1);
    $pdf->Cell(30,10,'Internetprotocol',1,0,'C');
    
    $target_path2 = "internetprotocol.txt";
    $txt = fopen($target_path2, 'r');
    $data = fread($txt, filesize($target_path2));
    fclose($txt);
    
    $pdf->MultiCell(80, 5, $data, 0, 'J', false);
    $pdf->Ln(20);
    
    //$pdf->SetAutoPageBreak(true, pdf_margin_bottom);
    
    $target_path3 = "internetprotocol2.txt";
    $txt2 = fopen($target_path3, 'r');
    $data2 = fread($txt2, filesize($target_path3));
    fclose($txt2);
    
    //$pdf->MultiCell(80, 5, $data2, 0, 0, 'L', false);
    $pdf->AddPage('P', 'A4');
    $pdf->Cell(0, 1, '', 0, 1);
    $pdf->Cell(60, 5, 'Naam' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["naam"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'Email' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["emailadres"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'Naam-school' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["naamSchool"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'Website-school' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["websiteSchool"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'Adres-school' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["adresSchool"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'plaats-postcode' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["plaats-postcode"], 1, 1, 'L');
    $pdf->Cell(60, 5, 'Overig' , 1, 0, 'L');
    $pdf->Cell(60, 5, $_POST["Overig"], 1, 1, 'L');
    $pdf->Output('Gegevens.pdf','F');
    
    if($pdf)
    {
     $pdf = file_get_contents('Gegevens.pdf');
     header('Content-Type: application/pdf');
     header('Content-Disposition: attachment; filename="Gegevens.pdf"');
     header('Content-Length: ' . strlen($pdf));
     echo $pdf;
    }
   }
  
   else
   {
    if(isset($_POST['verzenden']))
    {
     echo "<script>";
     echo "alert('alle velden moet ingevuld zijn')";
     echo "</script>";
     echo "PDF is niet aangemaakt";
    }
   }
?>
</body>
</html>

 

Thanks.

 

990wes






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com