Converting PDF Files using PHP By Idris Winarno

Slides:



Advertisements
Similar presentations
Microsoft ® Office Word 2007 Training Header and footer basics Sweetwater ISD presents:
Advertisements

With Folder HelpDesk for Outlook, support centres and other helpdesks can work efficiently with support cases inside Microsoft Outlook. The support tickets.
Presentation Heading – font Arial
Page Numbers, Headers, and Footers
1 After completing this lesson, you will be able to: Add a header and footer to a worksheet. Change margins and center a worksheet. Change the orientation.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Header and footer basics Add page numbers, date, and more Think of page formatting in a book. The book title is at the top of one page, the chapter title.
Chapter Apache Installation on Linux. Acknowledgement The contribution made by Darrin Morison is acknowledged.
Building Web Pages With Microsoft Office. Introduction This tutorial is for the beginning web builder. It utilizes software that you already have, Microsoft.
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
TITLE: Template for a 84.1 cm wide x cm tall poster (A0)
The Dr ü G Book: An Intro to Drupal The Dr ü G Book: An Intro to Drupal (Dr ü G: Drupal User ’ s Group - users, not developers) This is an introduction.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Preparing for Electronic Distribution Lesson 14.
From Baan and ERP Ln to Excel, Word, PDF, HTML, XML & Notepad in one click! B2Win 6.6.
Microsoft ® Word Templates and Accessibility. 1 What is a Word template? File with a.dot (document template) extension Can define the following:  Paragraph.
When running the CTAS MS Access database modules you may see this security warning This indicates that all scripting within the database has been disabled.
Nic Shulver, Other Useful PHP Bits More Useful PHP Read the contents list in the PHP online manual You will find loads of interesting.
Printing Procedure To print, please make sure there is a check mark in the “Scale to Fit Paper” check box in the Print Layout menu. Points to Note The.
How to Make a Power Point By Jeff Hinton Go to Slide 2. (You can get there by going to VIEW – SLIDE SORTER.)
Information and Mapping in the Public Interest
Mozilla Suite 1.7 Web Browser and newsgroup client, IRC chat client, and HTML editing Download:
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
From Baan and ERP Ln to Excel, Word, PDF, HTML, XML & Notepad in one click! B2Win 7.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
GILLINGS SCHOOL OF GLOBAL PUBLIC HEALTH Insert date here Title of presentation goes here Example image.
IReport Demo Spring 2008 OEDSA Conference. Report Properties.
14. Uploading Files to MySQL Database. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan.
Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
From Baan to Excel, Word, PDF, HTML, XML & Notepad in one click! B2Win 6.0.
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
PHP “Personal Home Page Hypertext Pre-processor” (a recursive acronym) Allows you to create dynamic web pages and link web pages to a database.
How to Make a Power Point By Jeff Hinton (revised by Diana Leiter) Go to Slide 2. (You can get there by going to VIEW – SLIDE SORTER.)
Updating to X6 Mike DeButts. Updating to X6 How to Install X6 What Not to do when Updating to X6 Migration Utility New File Locations introduced in X6.
Lab 8 Overview Apache Web Server. SCRIPTS Linux Tricks.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
XP Adding Headers and Footers Text that is printed at the top of every page is called a header A footer is text that is printed at the bottom of every.
Your current Moodle 1.9 Minimum Requirements Ability to do a TEST RUN! Upgrading Moodle to Version 2 By Ramzan Jabbar Doncaster College for the Deaf By.
NX Documentation Using Windows IIS (Internet Information Services) as a http server for NX documentation.
To create text styles click on Home >> Tab under Change Styles
Building Your Own Website Using:. Install & configure LAMP. Download WordPress and run it as a local website on your Raspberry Pi. Configure WordPress.
WordPress and Etherpad with BlueMix and Docker. Our aim is to run on BlueMix containers (now in beta) these two famous services In the BlueMix dashboard,
How to Apply PDF in Flipbook on Website. Description If you are finding solution for applying PDF in flipbook mode on website, and adding multimedia items.
Welcome to the Basic Microsoft Word Guide. Before you start this Guide, you will need to complete “Basic Computer”; “Basic Windows” and know how to type.
Installing iHRIS Install iHRIS Manage on an Ubuntu System
TITLE: Template for a 84.1 cm wide x cm tall poster (DIN A0)
Installation of MySQL Objectives Contents Practical Summary
From Baan and ERP Ln to Excel, Word, PDF, HTML, XML & Notepad in one click! B2Win 7.
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
>> PHP: HTML Integration
Kanban Task Manager for Outlook ‒ Introduction
Page Layout Header & Footer Font Styles Image wrapping List Styles
Chapter 2 Getting Started with PHP PHP Programming with MySQL
Personal Computer Club
Title: Tech Training Certificate: Ace of Initiative Program
Small corporate logo may Go here
Paper Title as it appears on the PDF
Paper Title as it appears on the PDF
Configuring Internet-related services
Title of Poster Arial 88 pt Centered on Poster Small Caps
Microsoft PowerPoint 2007 – Unit 2
How to Make a Power Point
Author’s Name/s Goes Here
A Tutorial for Students Word 2003 Version
Author’s Name/s Goes Here
Click to Insert Title - Arial 36pt
Poster Title Authors’ Names Institution/Organization/Company
Presentation transcript:

Converting PDF Files using PHP By Idris Winarno

Tools FPDF PDFlib HTML_ToPDF

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

Testing FPDF (1) <?php require('fpdf.php'); $pdf=new FPDF('P','mm','A4'); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); ?>

Testing FPDF (2) <?php require('fpdf.php'); class PDF extends FPDF { //Page header function Header() { //Logo $this->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(); ?>

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 "extension=pdf.so" >> /etc/php4/conf.d/pdf_lib.ini – echo "extension=pdf.so" >> /etc/php5/conf.d/pdf_lib.ini Checking yout config – apache2ctl configtest Syntax OK Restart your apache – # /etc/init.d/apache2 restart

Alternative install of PDFLib # cd /usr/src/ # wget Or # wget p4.tar.gzhttp://lecturer.eepis-its.edu/~idris/files/aplikasi_web/PDFlib-Lite p4.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 pdflib.so into your php.ini # /etc/init.d/apache2 restart

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

PDFLib Example <?php $p = PDF_new(); /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_begin_document($p, "", "") == 0) { die("Error: ". PDF_get_errmsg($p)); } PDF_set_info($p, "Creator", "hello.php"); PDF_set_info($p, "Author", "Rainer Schaaf"); PDF_set_info($p, "Title", "Hello world (PHP)!"); PDF_begin_page_ext($p, 595, 842, ""); $font = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); PDF_setfont($p, $font, 24.0); PDF_set_text_pos($p, 50, 700); PDF_show($p, "Hello world!"); PDF_continue_text($p, "(says PHP)"); PDF_end_page_ext($p, ""); PDF_end_document($p, ""); $buf = PDF_get_buffer($p); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf; PDF_delete($p); ?>

HTML_ToPDF Download source – # cd /usr/src – #wget tar.gzhttp:// 3.5.tar.gz or – wget its.edu/~idris/files/aplikasi_web/HTML_ToPDF-3.5.tar.gzhttp://lecturer.eepis- its.edu/~idris/files/aplikasi_web/HTML_ToPDF-3.5.tar.gz 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

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

HTML_ToPDF Test <?php /** $Id: example1.php :59:26Z jrust $ */ /** * The simplest example. We convert an HTML file into a PDF file. * We also add a few custom headers/footers to the PDF. */ ?> Testing HTML_ToPDF Creating the PDF from local HTML file.... Note that we customize the headers and footers! <?php // Require the class require_once dirname(__FILE__). '/../HTML_ToPDF.php'; // Full path to the file to be converted $htmlFile = dirname(__FILE__). '/test.html'; // The default domain for images that use a relative path // (you'll need to change the paths in the test.html page // to an image on your server) $defaultDomain = ' // Full path to the PDF we are creating $pdfFile = dirname(__FILE__). '/timecard.pdf'; // Remove old one, just to make sure we are making it // Instnatiate the class with our variables $pdf =& new HTML_ToPDF($htmlFile, $defaultDomain, $pdfFile); // Set headers/footers $pdf->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

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)

THANK YOU