Training, Open Source Computer Languages

This is page http://www.wellho.net/mouth/3817_Fpd ... ogram.html

Our email: info@wellho.net • Phone: 01144 1225 708225

Fpdf - generating .pdf documents easily from your PHP program

Generating a .pdf file from PHPYou can generate .pdf files from within a PHP page using the fpdf module which you can download from fpdf.org. It's quick to grab, easy to set up (pure PHP), and free of charge / royalty. Until today's PHP Techniques course, it was just one of thousands of modules that I know are out there, but I've not had a chance to try. But a customer requirement today (specifically a discussion about a use of instance variables - another story) lead us to download and try the class.

In Summary - use is as easy as
1. Load the class
  require('fpdf.php');

2. Create a new FPDF object
  $pdf = new FPDF();

3. Add a page to the output document
  $pdf-> AddPage();

4. Set the font and font size
  $pdf-> SetFont('Arial', 'B',16);

5. Add your text
  $pdf-> Cell(80, 8,'07:00 - 09:00 - Breakfast',0,1,"C");

6. Send the pdf to the browser
  $pdf-> Output();

Clearly there are lots of repeats of these lines to create the sample I have shown above, and I've used setmargin, setx, sety and settextcolor too ... full code [here].

Pre-requisite to using classes such as these:
a) Some knowledge about the take they'll undertake (you must be able to answer "What is a .pdf"?)
b) Knowledge of Object Orientation and how it works in PHP - see [here] for the appropriate course if you know PHP, but "OO" is new to you!

(written 2012-07-24, updated 2012-08-11)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H309 - PHP - Maps, Graphics and Geographics
  [4178] Where are you? How to write a geosensitive application - (2013-09-18)
  [3734] QR codes with marketing logos embedded - (2012-05-16)
  [3584] QR codes - graphics images that provide quick phone links - (2012-01-18)
  [3536] UK Mapping Data - and more to come - under government Open Data measures - (2011-12-03)
  [3447] Needle in a haystack - finding the web server overload - (2011-09-18)
  [3211] Computer Graphics in PHP - World (incoming data) to Pixel (screen) conversion - (2011-03-24)
  [3197] Finding and diverting image requests from rogue domains - (2011-03-08)
  [3133] An image from a website that occasionally comes out as hyroglyphics - (2011-01-14)
  [3027] Server logs - drawing a graph of gathered data - (2010-11-03)
  [2939] Protecting your images from use out of context - (2010-08-29)
  [2729] Uploading a document or image to its own URL via a browser - (2010-04-18)
  [2675] Redirecting to your main domain for correct security keys - (2010-03-13)
  [2583] Reducing image size on digital photos - PHP - (2010-01-17)
  [2390] Dynamic / changing images on your web page - (2009-09-01)
  [2361] Geocoding - converting address to latitude / Longitude with PHP via Google - (2009-08-14)
  [2343] World Flags in your PHP pages - (2009-08-10)
  [1956] Images for Christmas - (2008-12-21)
  [1923] Making it all worthwhile - (2008-12-04)
  [1756] Ever had One of THOSE mornings? - (2008-08-16)
  [1752] Dynamic maps / geographics in PHP - (2008-08-13)
  [1734] All around the world? - (2008-08-03)
  [1724] addslashes v mysql_real_escape_string in PHP - (2008-07-27)
  [1628] Gant charts - drawing them with a PHP script - (2008-05-03)
  [1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
  [1390] Converting from postal address to latitude / longitude - (2007-10-13)
  [1389] Controlling and labelling Google maps via PHP - (2007-10-13)
  [1194] Drawing hands on a clock face - PHP - (2007-05-19)
  [1104] Drawing dynamic graphs in PHP - (2007-03-09)
  [937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
  [665] PHP Image viewing application - (2006-04-01)
  [563] Merging pictures using PHP and GD - (2006-01-13)
  [320] Ordnance Survey - using a 'Get a map' - (2005-05-22)


Back to
Want to escape the Olympics? Learn to program in the countryside!
Previous and next
or
Horse's mouth home
Forward to
Making things happen - litter and ASB and lost dogs in Melksham
Some other Articles
Well House Manor at Dawn ... and later in the day
PHP sessions - a best practice teaching example
Packing a tar, jar or war file - best practise
Making things happen - litter and ASB and lost dogs in Melksham
Fpdf - generating .pdf documents easily from your PHP program
Want to escape the Olympics? Learn to program in the countryside!
The Melksham News - July 2012 - Part 2, TransWilts Rail, Wilts and Berks Canal
Returning guests - a sign of a good product. Cream teas and hotel rooms.
Injection Attacks - PHP, SQL, HTML, Javascript - and how to neutralise them
The Melksham News - July 2012 - Part 1, Campus and Chamber of Commerce
4254 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3817_Fpd ... ogram.html • PAGE BUILT: Sun Mar 30 15:20:58 2014 • BUILD SYSTEM: WomanWithCat