Presentation is loading. Please wait.

Presentation is loading. Please wait.

Converting PDF Files using PHP By Idris Winarno

Similar presentations

Presentation on theme: "Converting PDF Files using PHP By Idris Winarno"— Presentation transcript:

1 Converting PDF Files using PHP By Idris Winarno


3 FPDF Install your apache2 and PHP5 – # apt-get install apache2 php5 Install fpdf – # apt-get install fpdf Intergrate your fpdf into your php – ln -s /usr/share/fpdf/var/www/fpdf

4 Testing FPDF (1) AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); ?>

5 Testing FPDF (2) Image('logo_pb.png',10,8,33); //Arial bold 15 $this->SetFont('Arial','B',15); //Move to the right $this->Cell(80); //Title $this->Cell(30,10,'Title',1,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); for($i=1;$i<=40;$i++) $pdf->Cell(0,10,'Printing line number '.$i,0,1); $pdf->Output(); ?>

6 PDFLib Installing PDFLib – apt-get install libapache2-mod-php4 libapache2-mod-php4 – apt-get install php4-dev php5-dev php4-pear php5-pear – pear install pdflib --with-pdflib=/usr/local Adding new extension into php.ini – echo "" >> /etc/php4/conf.d/pdf_lib.ini – echo "" >> /etc/php5/conf.d/pdf_lib.ini Checking yout config – apache2ctl configtest Syntax OK Restart your apache – # /etc/init.d/apache2 restart

7 Alternative install of PDFLib # cd /usr/src/ # wget Or # wget 7.0.4p4.tar.gz 7.0.4p4.tar.gz # tar xvf PDFlib-Lite-7.0.4p4.tar.gz # cd PDFlib-Lite-7.0.4p4 #./configure # make # make install # pecl install pdflib # install dir /usr/local Adding into your php.ini # /etc/init.d/apache2 restart

8 PDFLib phpinfo() PDF Support => enabled PDFlib GmbH Version => 4.0.1 Revision => $Revision: 1.8 $ Pdflib 4.0.1 - installation ok

9 PDFLib Example

10 HTML_ToPDF Download source – # cd /usr/src – #wget 3.5.tar.gz 3.5.tar.gz or – wget http://lecturer.eepis- Make symbolic link into /var/www – # ln -s /usr/src/HTML_ToPDF-3.5 /var/www/html2pdf Installaing html2ps & ps2pdf – # apt-get install html2ps – # apt-get install texlive-latex-recommended

11 Creating HTML This HTML code will be converted into PDF Make your own HTML code

12 HTML_ToPDF Test Testing HTML_ToPDF Creating the PDF from local HTML file.... Note that we customize the headers and footers! setHeader('color', 'blue'); $pdf->setFooter('left', 'Generated by HTML_ToPDF'); $pdf->setFooter('right', '$D'); $result = $pdf->convert(); // Check if the result was an error if (is_a($result, 'HTML_ToPDFException')) { die($result->getMessage()); } else { echo "PDF file created successfully: $result"; echo ' Click here to view the PDF file.'; } ?> Please note that your folder permission is fully open

13 It’s your turn How to make a PDF file converted into database and shown by PHP files Please adapt into Final Project files (pdf files) to capture the abstract page (id and en)


Download ppt "Converting PDF Files using PHP By Idris Winarno"

Similar presentations

Ads by Google