PHP Classes

File: readme.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of wayne a munro  >  classPdf  >  readme.php  >  Download  
File: readme.php
Role: Example script
Content type: text/plain
Description: demo file
Class: classPdf
Author: By
Last change:
Date: 13 years ago
Size: 4,259 bytes


Class file image Download
// this is the php file which creates the readme.pdf file, this is not seriously
// suggested as a good way to create such a file, nor a great example of prose,
// but hopefully it will be useful
// adding ?d=1 to the url calling this will cause the pdf code itself to ve echoed to the
// browser, this is quite useful for debugging purposes.
// there is no option to save directly to a file here, but this would be trivial to implement.
// note that this file comprisises both the demo code, and the generator of the pdf documentation

// don't want any warnings turning up in the pdf code if the server is set to 'anal' mode.


// I am in NZ, so will design my page for A4 paper.. but don't get me started on that.
// (defaults to legal)
// this code has been modified to use ezpdf.

$pdf = new Cezpdf('a4','portrait');

$pdf -> ezSetMargins(50,70,50,50);

// put a border round all the pages
$all = $pdf->openObject();
// note that object can be told to appear on just odd or even pages by changing 'all' to 'odd'
// or 'even'.


// select a font

$pdf->ezText("PHP Pdf Creation\n",30,array('justification'=>'centre'));
$pdf->ezText("Module-free creation of Pdf documents\nfrom within PHP\n",20,array('justification'=>'centre'));
$pdf->ezText("developed by R&OS Ltd\n\n\nversion 0.05",18,array('justification'=>'centre'));

// modified to use the local file if it can

if (file_exists('ros.jpg')){
} else {
// comment out these two lines if you do not have GD jpeg support
  // I couldn't quickly see a way to test for this support from the code.
  // you could also copy the file from the locatioin shown and put it in the directory, then
  // the code above which doesn't use GD will be activated.
$img = ImageCreatefromjpeg('');
$pdf-> addImage($img,199,$pdf->y-100,200,0);

// load up the document content



$height = $pdf->getFontHeight($size);

foreach (
$data as $line){
// go through each line, showing it as required, if it is surrounded by '<>' then
  // assume that it is a title
  if (
// comment, or new page request
if ($line=='#NP'){
  } else if ((
$line[1]=='<' || $line[0]=='<') && $line[strlen($line)-1]=='>') {
// then this is a title
  } else {
// then this is just text
    // the ezpdf function will take care of all of the wrapping etc.

// show all the fonts that we have

addTitle($pdf,$y,30,'Font Sampler (basic fonts)');


foreach($fonts as $font){

if ($d){
$pdfcode = $pdf->ezOutput(1);
$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
} else {