Home
PHP
Application
Php Manual
Pictures
GuestBook
 
 
  Introduction Dlog Aprint SpTpl 
  Yap Xml2Array

 

 

 
 
 
Ex. index Quick Start Basic ex.
1st report Database Columns
Pdf output Pdf report Tag function
   

Pdf example.

Here I'll show you an simple example how to configure, how to use the columnset and write it as PDF file.

The PHP script

<?php
/*
* Column test
* $Header: d:/cvs/classistd/sptpl/test/test18.php,v 2.2 2004/02/10 22:08:46 Administrator Exp $
*/
function foo()
{
return(
"text from foo");
}

function
foop($text)
{
return(
"my parameter:".$text);
}


require_once(
'../sptpl.php');
require_once(
'../sptpl.inc');
require_once(
'../sptpl_db.php');

set_time_limit(0);
$t=new sptpl();
$t->LoadTemplate('test21.xml');
$t->SetVar("name","George");
$t->SetVar("MyName","Sam");
$bar['foo']='Index foo';
$t->SetVar("bar",$bar);
// $t->_DumpInternals();
// die;
$t->run("test21.pdf");
?>

Second step, write the configuration file test21.xml

<?xml version='1.0' ?>

<template>
<pagemanager>CPagePdf</pagemanager>

<!-- Notice, the font face is the font filename -->
<font id='text' face='Helvetica.afm' size='12'/>

<constant name='const1' value = '1'/>
<constant name='const2' value = '2'/>

<field name='fld1'>
  <sourcefield>fld1</sourcefield>
  <stringformat>none</stringformat>
  <dateformat>none</dateformat>
  <value>13</value>
</field>


<report>
  <beginreport>
   Hi

   My First Test
  </beginreport>
  <OpenPage>
Column test 1
  </OpenPage>
  <row id='pippo'>
Some text without set the column
  </row>

  <!-- set a new columnset -->
  <columnset id='test1'>
   <column  leftpos='60' Width='100' align='right' />
   <column  leftpos='170' Width='100' align='center' />
   <column  leftpos='280' Width='100' align='left' />
  </columnset>

  <!-- Now write the following text using the columnset test1,
  at column 1 -->

  <row columnset='test1' column='1' fontid='text'>Text on the first column
  </row>

  <!-- Some text at column 2. Notice I already activated the columnset
  test1, so I don't need add the columnset attribute -->

  <row column='2' fontid='text'>Text on the second column
  </row>

  <row column='3' fontid='text'>Text on the third column
  </row>

  <!-- Are the texts place in the right position? Notice
  the align became from the column definition. If I add the
  align attribute to the following row tag, it overrides the column
  definition -->

  <row column='1' fontid='text'>Align: right
  </row>

  <row column='2' fontid='text'>Align: center
  </row>

  <row column='3' fontid='text'>Align: left
  </row>

  <newpage/>

  <!-- No column set, the module writes the text into column 0
  that is the whole page -->

  <row fontid='text'>Another page</row>

  <row vpos='absolute' rowpos='50'/>
  <row fontid='text'>Another text</row>

  <closepage>
Page end - {$PageNumber}
  </closepage>
  <closereport>
   End!That's all folk!
  </closereport>


</report>


</template>

And here you may see the output

 

Copyright © 2003-2008 Darvin Andrioli, last change 31/07/2006