commit 311456e6bd8f8b3f6e536fa50f3821a6cfc1175d
parent a4c6dc5ae3994139396f747ab0b56a741b0245e6
Author: dankert <devnull@localhost>
Date: Sat, 18 Apr 2009 02:46:31 +0200
PDF-Renderer fertig gestellt (reine Textausgabe, Links werden gesetzt).
Diffstat:
14 files changed, 1628 insertions(+), 1656 deletions(-)
diff --git a/textClasses/renderer/PdfRenderer.class.php b/textClasses/renderer/PdfRenderer.class.php
@@ -2,7 +2,7 @@
/**
* Dokument-Objekt.<br>
- * Diese Objekt verkörpert das Root-Objekt in einem DOM-Baum.<br>
+ * Diese Objekt verkoerpert das Root-Objekt in einem DOM-Baum.<br>
* <br>
* Dieses Objekt kann Text parsen und seine Unterobjekte selbst erzeugen.<br>
*
@@ -18,12 +18,15 @@ class PdfRenderer
var $linkedObjectIds = array();
/**
- * Fußnoten.
*
* @var Array
*/
var $footnotes = array();
-
+
+ var $fpdf;
+
+ var $url;
+
/**
* Rendert ein Dokument-Element.
@@ -35,118 +38,26 @@ class PdfRenderer
{
global $conf;
- $attr = array();
- $val = '';
- $praefix = '';
- $suffix = '';
- $empty = false;
-
- if ( count($child->children) > 0 )
- {
- $subChild1 = $child->children[0];
-
- if ( !empty($subChild1->class) )
- $attr['class'] = $subChild1->class;
-
- if ( !empty($subChild1->style) )
- $attr['style'] = $subChild1->style;
-
- if ( !empty($subChild1->title) )
- $attr['title'] = $subChild1->title;
- }
-
switch( strtolower(get_class($child)) )
{
case 'tableofcontentelement':
- $tag = 'p';
- foreach( $this->children as $h)
- {
- if ( strtolower(get_class($h))=='headlineelement' )
- {
- $child->children[] = new RawElement(str_repeat(' ',$h->level));
- $t = new TextElement( $h->getText() );
- $l = new LinkElement();
- $l->fragment=$h->getName();
- $l->children[] = $t;
- $child->children[] = $l;
- $child->children[] = new LineBreakElement();
- }
- }
break;
case 'rawelement':
- $tag = '';
- $val = $child->src;
+ $this->fpdf->Write(5,$child->src);
break;
case 'textelement':
- $tag = '';
-// $tag = 'span';
-
- $val = $child->text;
- if ( ! $this->element->html )
- $val = Text::encodeHtml( $val );
- $val = Text::replaceHtmlChars( $val );
+
+ $this->fpdf->Write(10,$child->text,$this->url);
+ $this->url = '';
break;
case 'footnoteelement':
- $tag = 'a';
- $attr['href'] = '#footnote';
-
- $title = '';
- foreach( $child->children as $c )
- $title .= $this->renderElement($c);
- $attr['title'] = strip_tags($title);
-
- $nr = 1;
- foreach( $this->footnotes as $fn )
- if ( strtolower(get_class($fn))=='linebreakelement')
- $nr++;
-
- $val = $nr;
- if ( @$conf['editor']['footnote']['bracket'])
- $val = '('.$nr.')';
- if ( @$conf['editor']['footnote']['sup'])
- $val = '<sup><small>'.$nr.'</small></sup>';
-
-
- if ( $nr == 1 )
- {
- $this->footnotes[] = new RawElement('—');
- $le = new LinkElement();
- $le->name = "footnote";
- $this->footnotes[] = $le;
- $this->footnotes[] = new RawElement('—');
- }
- $this->footnotes[] = new LineBreakElement();
- $this->footnotes[] = new RawElement($val);
- $this->footnotes[] = new RawElement(' ');
- foreach( $child->children as $c )
- $this->footnotes[] = $c;
-
- $child->children = array();
-
break;
case 'codeelement':
-
- if ( empty($child->language) )
- // Wenn keine Sprache verfügbar, dann ein einfaches PRE-Element erzeugen.
- $tag = 'pre';
- else
- {
- // Wenn Sprache verfügbar, dann den GESHI-Parser bemühen.
- $tag = '';
- $source = '';
- foreach( $child->children as $c )
- if ( strtolower(get_class($c)) == 'textelement')
- $source .= $c->text."\n";
- $child->children = array();
- require_once('./geshi/geshi.php');
- $geshi = new Geshi($source,$child->language);
- $val = $geshi->parse_code();
- }
break;
case 'quoteelement':
@@ -155,257 +66,78 @@ class PdfRenderer
case 'paragraphelement':
- $tag = 'p';
+ $this->fpdf->ln(10);
break;
case 'speechelement':
- $tag = 'cite';
-
- // Danke an: http://www.apostroph.de/tueddelchen.php
- //TODO: Abhängigkeit von Spracheinstellung implementieren.
- $language = 'de';
- switch( $language )
- {
- case 'de': // deutsche Notation
- $praefix = '„';
- $suffix = '“';
- break;
- case 'fr':
- $praefix = '«';
- $suffix = '»';
- break;
- default: // englische Notation
- $praefix = '“';
- $suffix = '”';
- }
-
- if ( $conf['editor']['html']['override_speech'] )
- {
- $praefix = $conf['editor']['html']['override_speech_open' ];
- $suffix = $conf['editor']['html']['override_speech_close'];
- }
break;
case 'linebreakelement':
- $tag = 'br';
- $empty = true;
+ $this->fpdf->ln(5);
break;
-
+
case 'linkelement':
- $tag = 'a';
- if ( !empty($child->name) )
- $attr['name'] = $child->name;
- else
- $attr['href'] = htmlspecialchars($child->getUrl());
-
- if ( Object::available( $child->objectId ) )
- {
- $file = new File( $child->objectId );
- $file->load();
- $attr['title'] = $file->description;
- unset( $file );
- }
+ $this->url = $child->getUrl();
break;
case 'imageelement':
- $empty = true;
- $attr['alt'] = '';
-
- if ( ! Object::available( $child->objectId ) )
- {
- $tag = '';
- }
- elseif ( empty($attr['title']) )
- {
- $tag = 'img';
- $attr['src'] = $child->getUrl();
- $attr['border'] = '0';
-
- // Breite/Höhe des Bildes bestimmen.
- $image = new File( $child->objectId );
-
- $image->load();
- $attr['alt' ] = $image->name;
- $attr['title' ] = $image->description;
-
- $image->getImageSize();
- $attr['width' ] = $image->width;
- $attr['height'] = $image->height;
- unset($image);
- }
- else
- {
- $tag = 'dl';
-
- if ( empty($attr['class']) )
- $attr['class'] = "image";
-
- $child->children = array();
- $dt = new DefinitionListItemElement();
- $dt->children[] = new TextElement('(image)');
- $dt->children[] = $child;
- $child->children[] = $dt;
-
- $dd = new DefinitionListEntryElement();
- $dd->children[] = new TextElement('(image)');
- $dd->children[] = new TextElement($attr['title']);
- $child->children[] = $dd;
- }
break;
case 'strongelement':
- $tag = 'strong';
break;
case 'emphaticelement':
- $tag = 'em';
break;
case 'insertedelement':
- $tag = 'ins';
break;
case 'removedelement':
- $tag = 'del';
break;
case 'headlineelement':
- $tag = 'h'.$child->level;
-
- $l = new LinkElement();
- $l->name = $child->getName();
- $child->children[] = $l;
-
+ $this->fpdf->ln(20);
break;
case 'tableelement':
- $tag = 'table';
break;
case 'tablelineelement':
- $tag = 'tr';
break;
case 'definitionlistelement':
- $items = $child->children;
- $newChildren = array();
- foreach( $items as $item )
- {
- $def = new DefinitionItemElement();
- $def->key = $item->key;
- $item->key = '';
- $newChildren[] = $def;
- $newChildren[] = $item;
- }
-// Html::debug($newChildren,'Children-neu');
- $child->children = $newChildren;
- $tag = 'dl';
break;
case 'definitionitemelement':
- if ( !empty($child->key) )
- {
- $tag = 'dt';
- $val = $child->key;
- }
- else
- {
- $tag = 'dd';
- }
break;
case 'tablecellelement':
- if ( $child->isHeading )
- $tag = 'th'; else $tag = 'td';
-
- if ( $child->rowSpan > 1 )
- $attr['rowspan'] = $child->rowSpan;
- if ( $child->colSpan > 1 )
- $attr['colspan'] = $child->colSpan;
break;
case 'listelement':
- $tag = 'ul';
break;
case 'teletypeelement':
- $tag = 'code';
break;
case 'numberedlistelement':
- $tag = 'ol';
break;
case 'listentryelement':
- $tag = 'li';
break;
default:
-
- $tag = 'unknown-element';
- $attr['class'] = strtolower(get_class($child));
break;
}
- $val .= $praefix;
foreach( $child->children as $c )
{
- $val .= $this->renderElement( $c );
+ $this->renderElement( $c );
}
-
- $val .= $suffix;
-// echo "text:$val";
- return $this->renderHtmlElement($tag,$val,$empty,$attr);
}
-
- /**
- * Erzeugt ein HTML-Element.
- *
- * @param String $tag Name des Tags
- * @param String $value Inhalt
- * @param boolean $empty abkürzen, wenn Inhalt leer ("<... />")
- * @param Array $attr Attribute als Array<String,String>
- * @return String
- */
- function renderHtmlElement( $tag,$value,$empty,$attr=array() )
- {
- global $conf;
- if ( $tag == '' )
- return $value;
-
- $val = '<'.$tag;
- foreach( $attr as $attrName=>$attrInhalt )
- {
- $val .= ' '.$attrName.'="'.$attrInhalt.'"';
- }
-
- if ( $value == '' && $empty )
- {
- // Inhalt ist leer, also Kurzform verwenden.
- // Die Kurzform ist abhängig vom Rendermode.
- // SGML=<tag>
- // XML=<tag />
- if ( $conf['editor']['html']['rendermode'] == 'xml' )
- {
- $val .= ' />';
- return $val;
- }
- else
- {
- $val .= '>';
- return $val;
- }
- }
-
- $val .= '>'.$value.'</'.$tag.'>';
- return $val;
- }
-
-
-
/**
* Rendering des Dokumentes.<br>
*
@@ -413,16 +145,19 @@ class PdfRenderer
*/
function render()
{
- $this->renderedText = '';
+ $this->fpdf = new FPDF();
+ $this->fpdf->AddPage();
+ $this->fpdf->SetFont('Arial','',12);
+
$this->footnotes = array();
foreach( $this->children as $child )
- $this->renderedText .= $this->renderElement( $child );
-
- foreach( $this->footnotes as $child )
- $this->renderedText .= $this->renderElement( $child );
+ $this->renderElement( $child );
- return $this->renderedText;
+ #foreach( $this->footnotes as $child )
+ # $this->renderElement( $child );
+
+ return $this->fpdf->Output('','S');
}
}
diff --git a/textClasses/renderer/font/courier.php b/textClasses/renderer/font/courier.php
@@ -0,0 +1,7 @@
+<?php
+for($i=0;$i<=255;$i++)
+ $fpdf_charwidths['courier'][chr($i)]=600;
+$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];
+$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];
+$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];
+?>
diff --git a/textClasses/renderer/font/helvetica.php b/textClasses/renderer/font/helvetica.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['helvetica']=array(
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
+ 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
+ chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
+ chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
+?>
diff --git a/textClasses/renderer/font/helveticab.php b/textClasses/renderer/font/helveticab.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['helveticaB']=array(
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
+ 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
+ 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
+ chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
+ chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
+?>
diff --git a/textClasses/renderer/font/helveticabi.php b/textClasses/renderer/font/helveticabi.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['helveticaBI']=array(
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
+ 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
+ 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
+ chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
+ chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
+?>
diff --git a/textClasses/renderer/font/helveticai.php b/textClasses/renderer/font/helveticai.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['helveticaI']=array(
+ chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
+ chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
+ ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
+ 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
+ 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
+ chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
+ chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
+ chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
+?>
diff --git a/textClasses/renderer/font/readme.txt b/textClasses/renderer/font/readme.txt
@@ -0,0 +1 @@
+Font-files for FPDF-Library+
\ No newline at end of file
diff --git a/textClasses/renderer/font/symbol.php b/textClasses/renderer/font/symbol.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['symbol']=array(
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
+ ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
+ 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
+ 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
+ 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
+ chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
+ chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
+ chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
+ chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
+ chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
+ chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
+?>
diff --git a/textClasses/renderer/font/times.php b/textClasses/renderer/font/times.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['times']=array(
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
+ 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
+ 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
+ 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
+ chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
+ chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
+ chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
+?>
diff --git a/textClasses/renderer/font/timesb.php b/textClasses/renderer/font/timesb.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['timesB']=array(
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
+ 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
+ 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
+ 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
+ chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
+ chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
+ chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
+?>
diff --git a/textClasses/renderer/font/timesbi.php b/textClasses/renderer/font/timesbi.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['timesBI']=array(
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
+ 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
+ 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
+ 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
+ chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
+ chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
+ chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
+ chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
+?>
diff --git a/textClasses/renderer/font/timesi.php b/textClasses/renderer/font/timesi.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['timesI']=array(
+ chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
+ chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
+ ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
+ 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
+ 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
+ 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
+ chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
+ chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
+ chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
+ chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
+ chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
+ chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
+?>
diff --git a/textClasses/renderer/font/zapfdingbats.php b/textClasses/renderer/font/zapfdingbats.php
@@ -0,0 +1,15 @@
+<?php
+$fpdf_charwidths['zapfdingbats']=array(
+ chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
+ chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
+ ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
+ 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
+ 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
+ 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
+ chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
+ chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
+ chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
+ chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
+ chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
+ chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
+?>
diff --git a/textClasses/renderer/fpdf.php b/textClasses/renderer/fpdf.php
@@ -1,1647 +1,1725 @@
<?php
/*******************************************************************************
-* Software: FPDF *
-* Version: 1.53 *
-* Date: 2004-12-31 *
-* Author: Olivier PLATHEY *
-* License: Freeware *
-* *
-* You may use and modify this software as you wish. *
-*******************************************************************************/
-
-if(!class_exists('FPDF'))
-{
-define('FPDF_VERSION','1.53');
+ * FPDF *
+ * *
+ * Version: 1.6 *
+ * Date: 2008-08-03 *
+ * Author: Olivier PLATHEY *
+ *******************************************************************************/
-class FPDF
-{
-//Private properties
-var $page; //current page number
-var $n; //current object number
-var $offsets; //array of object offsets
-var $buffer; //buffer holding in-memory PDF
-var $pages; //array containing pages
-var $state; //current document state
-var $compress; //compression flag
-var $DefOrientation; //default orientation
-var $CurOrientation; //current orientation
-var $OrientationChanges; //array indicating orientation changes
-var $k; //scale factor (number of points in user unit)
-var $fwPt,$fhPt; //dimensions of page format in points
-var $fw,$fh; //dimensions of page format in user unit
-var $wPt,$hPt; //current dimensions of page in points
-var $w,$h; //current dimensions of page in user unit
-var $lMargin; //left margin
-var $tMargin; //top margin
-var $rMargin; //right margin
-var $bMargin; //page break margin
-var $cMargin; //cell margin
-var $x,$y; //current position in user unit for cell positioning
-var $lasth; //height of last cell printed
-var $LineWidth; //line width in user unit
-var $CoreFonts; //array of standard font names
-var $fonts; //array of used fonts
-var $FontFiles; //array of font files
-var $diffs; //array of encoding differences
-var $images; //array of used images
-var $PageLinks; //array of links in pages
-var $links; //array of internal links
-var $FontFamily; //current font family
-var $FontStyle; //current font style
-var $underline; //underlining flag
-var $CurrentFont; //current font info
-var $FontSizePt; //current font size in points
-var $FontSize; //current font size in user unit
-var $DrawColor; //commands for drawing color
-var $FillColor; //commands for filling color
-var $TextColor; //commands for text color
-var $ColorFlag; //indicates whether fill and text colors are different
-var $ws; //word spacing
-var $AutoPageBreak; //automatic page breaking
-var $PageBreakTrigger; //threshold used to trigger page breaks
-var $InFooter; //flag set when processing footer
-var $ZoomMode; //zoom display mode
-var $LayoutMode; //layout display mode
-var $title; //title
-var $subject; //subject
-var $author; //author
-var $keywords; //keywords
-var $creator; //creator
-var $AliasNbPages; //alias for total number of pages
-var $PDFVersion; //PDF version number
+define('FPDF_VERSION','1.6');
-/*******************************************************************************
-* *
-* Public methods *
-* *
-*******************************************************************************/
-function FPDF($orientation='P',$unit='mm',$format='A4')
+class FPDF
{
- //Some checks
- $this->_dochecks();
- //Initialization of properties
- $this->page=0;
- $this->n=2;
- $this->buffer='';
- $this->pages=array();
- $this->OrientationChanges=array();
- $this->state=0;
- $this->fonts=array();
- $this->FontFiles=array();
- $this->diffs=array();
- $this->images=array();
- $this->links=array();
- $this->InFooter=false;
- $this->lasth=0;
- $this->FontFamily='';
- $this->FontStyle='';
- $this->FontSizePt=12;
- $this->underline=false;
- $this->DrawColor='0 G';
- $this->FillColor='0 g';
- $this->TextColor='0 g';
- $this->ColorFlag=false;
- $this->ws=0;
- //Standard fonts
- $this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
- 'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
- 'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
- 'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
- //Scale factor
- if($unit=='pt')
+ var $page; //current page numberstrem
+ var $n; //current object number
+ var $offsets; //array of object offsets
+ var $buffer; //buffer holding in-memory PDF
+ var $pages; //array containing pages
+ var $state; //current document state
+ var $compress; //compression flag
+ var $k; //scale factor (number of points in user unit)
+ var $DefOrientation; //default orientation
+ var $CurOrientation; //current orientation
+ var $PageFormats; //available page formats
+ var $DefPageFormat; //default page format
+ var $CurPageFormat; //current page format
+ var $PageSizes; //array storing non-default page sizes
+ var $wPt,$hPt; //dimensions of current page in points
+ var $w,$h; //dimensions of current page in user unit
+ var $lMargin; //left margin
+ var $tMargin; //top margin
+ var $rMargin; //right margin
+ var $bMargin; //page break margin
+ var $cMargin; //cell margin
+ var $x,$y; //current position in user unit
+ var $lasth; //height of last printed cell
+ var $LineWidth; //line width in user unit
+ var $CoreFonts; //array of standard font names
+ var $fonts; //array of used fonts
+ var $FontFiles; //array of font files
+ var $diffs; //array of encoding differences
+ var $FontFamily; //current font family
+ var $FontStyle; //current font style
+ var $underline; //underlining flag
+ var $CurrentFont; //current font info
+ var $FontSizePt; //current font size in points
+ var $FontSize; //current font size in user unit
+ var $DrawColor; //commands for drawing color
+ var $FillColor; //commands for filling color
+ var $TextColor; //commands for text color
+ var $ColorFlag; //indicates whether fill and text colors are different
+ var $ws; //word spacing
+ var $images; //array of used images
+ var $PageLinks; //array of links in pages
+ var $links; //array of internal links
+ var $AutoPageBreak; //automatic page breaking
+ var $PageBreakTrigger; //threshold used to trigger page breaks
+ var $InHeader; //flag set when processing header
+ var $InFooter; //flag set when processing footer
+ var $ZoomMode; //zoom display mode
+ var $LayoutMode; //layout display mode
+ var $title; //title
+ var $subject; //subject
+ var $author; //author
+ var $keywords; //keywords
+ var $creator; //creator
+ var $AliasNbPages; //alias for total number of pages
+ var $PDFVersion; //PDF version number
+
+ /*******************************************************************************
+ * *
+ * Public methods *
+ * *
+ *******************************************************************************/
+ function FPDF($orientation='P', $unit='mm', $format='A4')
+ {
+ //Some checks
+ $this->_dochecks();
+ //Initialization of properties
+ $this->page=0;
+ $this->n=2;
+ $this->buffer='';
+ $this->pages=array();
+ $this->PageSizes=array();
+ $this->state=0;
+ $this->fonts=array();
+ $this->FontFiles=array();
+ $this->diffs=array();
+ $this->images=array();
+ $this->links=array();
+ $this->InHeader=false;
+ $this->InFooter=false;
+ $this->lasth=0;
+ $this->FontFamily='';
+ $this->FontStyle='';
+ $this->FontSizePt=12;
+ $this->underline=false;
+ $this->DrawColor='0 G';
+ $this->FillColor='0 g';
+ $this->TextColor='0 g';
+ $this->ColorFlag=false;
+ $this->ws=0;
+ //Standard fonts
+ $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
+ 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
+ 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
+ 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
+ //Scale factor
+ if($unit=='pt')
$this->k=1;
- elseif($unit=='mm')
+ elseif($unit=='mm')
$this->k=72/25.4;
- elseif($unit=='cm')
+ elseif($unit=='cm')
$this->k=72/2.54;
- elseif($unit=='in')
+ elseif($unit=='in')
$this->k=72;
- else
+ else
$this->Error('Incorrect unit: '.$unit);
- //Page format
- if(is_string($format))
- {
- $format=strtolower($format);
- if($format=='a3')
- $format=array(841.89,1190.55);
- elseif($format=='a4')
- $format=array(595.28,841.89);
- elseif($format=='a5')
- $format=array(420.94,595.28);
- elseif($format=='letter')
- $format=array(612,792);
- elseif($format=='legal')
- $format=array(612,1008);
+ //Page format
+ $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
+ 'letter'=>array(612,792), 'legal'=>array(612,1008));
+ if(is_string($format))
+ $format=$this->_getpageformat($format);
+ $this->DefPageFormat=$format;
+ $this->CurPageFormat=$format;
+ //Page orientation
+ $orientation=strtolower($orientation);
+ if($orientation=='p' || $orientation=='portrait')
+ {
+ $this->DefOrientation='P';
+ $this->w=$this->DefPageFormat[0];
+ $this->h=$this->DefPageFormat[1];
+ }
+ elseif($orientation=='l' || $orientation=='landscape')
+ {
+ $this->DefOrientation='L';
+ $this->w=$this->DefPageFormat[1];
+ $this->h=$this->DefPageFormat[0];
+ }
else
- $this->Error('Unknown page format: '.$format);
- $this->fwPt=$format[0];
- $this->fhPt=$format[1];
+ $this->Error('Incorrect orientation: '.$orientation);
+ $this->CurOrientation=$this->DefOrientation;
+ $this->wPt=$this->w*$this->k;
+ $this->hPt=$this->h*$this->k;
+ //Page margins (1 cm)
+ $margin=28.35/$this->k;
+ $this->SetMargins($margin,$margin);
+ //Interior cell margin (1 mm)
+ $this->cMargin=$margin/10;
+ //Line width (0.2 mm)
+ $this->LineWidth=.567/$this->k;
+ //Automatic page break
+ $this->SetAutoPageBreak(true,2*$margin);
+ //Full width display mode
+ $this->SetDisplayMode('fullwidth');
+ //Enable compression
+ $this->SetCompression(true);
+ //Set default PDF version number
+ $this->PDFVersion='1.3';
}
- else
+
+ function SetMargins($left, $top, $right=null)
{
- $this->fwPt=$format[0]*$this->k;
- $this->fhPt=$format[1]*$this->k;
+ //Set left, top and right margins
+ $this->lMargin=$left;
+ $this->tMargin=$top;
+ if($right===null)
+ $right=$left;
+ $this->rMargin=$right;
}
- $this->fw=$this->fwPt/$this->k;
- $this->fh=$this->fhPt/$this->k;
- //Page orientation
- $orientation=strtolower($orientation);
- if($orientation=='p' || $orientation=='portrait')
+
+ function SetLeftMargin($margin)
{
- $this->DefOrientation='P';
- $this->wPt=$this->fwPt;
- $this->hPt=$this->fhPt;
+ //Set left margin
+ $this->lMargin=$margin;
+ if($this->page>0 && $this->x<$margin)
+ $this->x=$margin;
}
- elseif($orientation=='l' || $orientation=='landscape')
+
+ function SetTopMargin($margin)
{
- $this->DefOrientation='L';
- $this->wPt=$this->fhPt;
- $this->hPt=$this->fwPt;
+ //Set top margin
+ $this->tMargin=$margin;
}
- else
- $this->Error('Incorrect orientation: '.$orientation);
- $this->CurOrientation=$this->DefOrientation;
- $this->w=$this->wPt/$this->k;
- $this->h=$this->hPt/$this->k;
- //Page margins (1 cm)
- $margin=28.35/$this->k;
- $this->SetMargins($margin,$margin);
- //Interior cell margin (1 mm)
- $this->cMargin=$margin/10;
- //Line width (0.2 mm)
- $this->LineWidth=.567/$this->k;
- //Automatic page break
- $this->SetAutoPageBreak(true,2*$margin);
- //Full width display mode
- $this->SetDisplayMode('fullwidth');
- //Enable compression
- $this->SetCompression(true);
- //Set default PDF version number
- $this->PDFVersion='1.3';
-}
-
-function SetMargins($left,$top,$right=-1)
-{
- //Set left, top and right margins
- $this->lMargin=$left;
- $this->tMargin=$top;
- if($right==-1)
- $right=$left;
- $this->rMargin=$right;
-}
-
-function SetLeftMargin($margin)
-{
- //Set left margin
- $this->lMargin=$margin;
- if($this->page>0 && $this->x<$margin)
- $this->x=$margin;
-}
-
-function SetTopMargin($margin)
-{
- //Set top margin
- $this->tMargin=$margin;
-}
-function SetRightMargin($margin)
-{
- //Set right margin
- $this->rMargin=$margin;
-}
+ function SetRightMargin($margin)
+ {
+ //Set right margin
+ $this->rMargin=$margin;
+ }
-function SetAutoPageBreak($auto,$margin=0)
-{
- //Set auto page break mode and triggering margin
- $this->AutoPageBreak=$auto;
- $this->bMargin=$margin;
- $this->PageBreakTrigger=$this->h-$margin;
-}
+ function SetAutoPageBreak($auto, $margin=0)
+ {
+ //Set auto page break mode and triggering margin
+ $this->AutoPageBreak=$auto;
+ $this->bMargin=$margin;
+ $this->PageBreakTrigger=$this->h-$margin;
+ }
-function SetDisplayMode($zoom,$layout='continuous')
-{
- //Set display mode in viewer
- if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
+ function SetDisplayMode($zoom, $layout='continuous')
+ {
+ //Set display mode in viewer
+ if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
$this->ZoomMode=$zoom;
- else
+ else
$this->Error('Incorrect zoom display mode: '.$zoom);
- if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
+ if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
$this->LayoutMode=$layout;
- else
+ else
$this->Error('Incorrect layout display mode: '.$layout);
-}
+ }
-function SetCompression($compress)
-{
- //Set page compression
- if(function_exists('gzcompress'))
+ function SetCompression($compress)
+ {
+ //Set page compression
+ if(function_exists('gzcompress'))
$this->compress=$compress;
- else
+ else
$this->compress=false;
-}
+ }
-function SetTitle($title)
-{
- //Title of document
- $this->title=$title;
-}
+ function SetTitle($title, $isUTF8=false)
+ {
+ //Title of document
+ if($isUTF8)
+ $title=$this->_UTF8toUTF16($title);
+ $this->title=$title;
+ }
-function SetSubject($subject)
-{
- //Subject of document
- $this->subject=$subject;
-}
+ function SetSubject($subject, $isUTF8=false)
+ {
+ //Subject of document
+ if($isUTF8)
+ $subject=$this->_UTF8toUTF16($subject);
+ $this->subject=$subject;
+ }
-function SetAuthor($author)
-{
- //Author of document
- $this->author=$author;
-}
+ function SetAuthor($author, $isUTF8=false)
+ {
+ //Author of document
+ if($isUTF8)
+ $author=$this->_UTF8toUTF16($author);
+ $this->author=$author;
+ }
-function SetKeywords($keywords)
-{
- //Keywords of document
- $this->keywords=$keywords;
-}
+ function SetKeywords($keywords, $isUTF8=false)
+ {
+ //Keywords of document
+ if($isUTF8)
+ $keywords=$this->_UTF8toUTF16($keywords);
+ $this->keywords=$keywords;
+ }
-function SetCreator($creator)
-{
- //Creator of document
- $this->creator=$creator;
-}
+ function SetCreator($creator, $isUTF8=false)
+ {
+ //Creator of document
+ if($isUTF8)
+ $creator=$this->_UTF8toUTF16($creator);
+ $this->creator=$creator;
+ }
-function AliasNbPages($alias='{nb}')
-{
- //Define an alias for total number of pages
- $this->AliasNbPages=$alias;
-}
+ function AliasNbPages($alias='{nb}')
+ {
+ //Define an alias for total number of pages
+ $this->AliasNbPages=$alias;
+ }
-function Error($msg)
-{
- //Fatal error
- die('<B>FPDF error: </B>'.$msg);
-}
+ function Error($msg)
+ {
+ //Fatal error
+ die('<b>FPDF error:</b> '.$msg);
+ }
-function Open()
-{
- //Begin document
- $this->state=1;
-}
+ function Open()
+ {
+ //Begin document
+ $this->state=1;
+ }
-function Close()
-{
- //Terminate document
- if($this->state==3)
+ function Close()
+ {
+ //Terminate document
+ if($this->state==3)
return;
- if($this->page==0)
+ if($this->page==0)
$this->AddPage();
- //Page footer
- $this->InFooter=true;
- $this->Footer();
- $this->InFooter=false;
- //Close page
- $this->_endpage();
- //Close document
- $this->_enddoc();
-}
-
-function AddPage($orientation='')
-{
- //Start a new page
- if($this->state==0)
- $this->Open();
- $family=$this->FontFamily;
- $style=$this->FontStyle.($this->underline ? 'U' : '');
- $size=$this->FontSizePt;
- $lw=$this->LineWidth;
- $dc=$this->DrawColor;
- $fc=$this->FillColor;
- $tc=$this->TextColor;
- $cf=$this->ColorFlag;
- if($this->page>0)
- {
//Page footer
$this->InFooter=true;
$this->Footer();
$this->InFooter=false;
//Close page
$this->_endpage();
+ //Close document
+ $this->_enddoc();
}
- //Start new page
- $this->_beginpage($orientation);
- //Set line cap style to square
- $this->_out('2 J');
- //Set line width
- $this->LineWidth=$lw;
- $this->_out(sprintf('%.2f w',$lw*$this->k));
- //Set font
- if($family)
- $this->SetFont($family,$style,$size);
- //Set colors
- $this->DrawColor=$dc;
- if($dc!='0 G')
- $this->_out($dc);
- $this->FillColor=$fc;
- if($fc!='0 g')
- $this->_out($fc);
- $this->TextColor=$tc;
- $this->ColorFlag=$cf;
- //Page header
- $this->Header();
- //Restore line width
- if($this->LineWidth!=$lw)
+
+ function AddPage($orientation='', $format='')
{
+ //Start a new page
+ if($this->state==0)
+ $this->Open();
+ $family=$this->FontFamily;
+ $style=$this->FontStyle.($this->underline ? 'U' : '');
+ $size=$this->FontSizePt;
+ $lw=$this->LineWidth;
+ $dc=$this->DrawColor;
+ $fc=$this->FillColor;
+ $tc=$this->TextColor;
+ $cf=$this->ColorFlag;
+ if($this->page>0)
+ {
+ //Page footer
+ $this->InFooter=true;
+ $this->Footer();
+ $this->InFooter=false;
+ //Close page
+ $this->_endpage();
+ }
+ //Start new page
+ $this->_beginpage($orientation,$format);
+ //Set line cap style to square
+ $this->_out('2 J');
+ //Set line width
$this->LineWidth=$lw;
- $this->_out(sprintf('%.2f w',$lw*$this->k));
- }
- //Restore font
- if($family)
+ $this->_out(sprintf('%.2F w',$lw*$this->k));
+ //Set font
+ if($family)
$this->SetFont($family,$style,$size);
- //Restore colors
- if($this->DrawColor!=$dc)
- {
+ //Set colors
$this->DrawColor=$dc;
+ if($dc!='0 G')
$this->_out($dc);
- }
- if($this->FillColor!=$fc)
- {
$this->FillColor=$fc;
+ if($fc!='0 g')
$this->_out($fc);
+ $this->TextColor=$tc;
+ $this->ColorFlag=$cf;
+ //Page header
+ $this->InHeader=true;
+ $this->Header();
+ $this->InHeader=false;
+ //Restore line width
+ if($this->LineWidth!=$lw)
+ {
+ $this->LineWidth=$lw;
+ $this->_out(sprintf('%.2F w',$lw*$this->k));
+ }
+ //Restore font
+ if($family)
+ $this->SetFont($family,$style,$size);
+ //Restore colors
+ if($this->DrawColor!=$dc)
+ {
+ $this->DrawColor=$dc;
+ $this->_out($dc);
+ }
+ if($this->FillColor!=$fc)
+ {
+ $this->FillColor=$fc;
+ $this->_out($fc);
+ }
+ $this->TextColor=$tc;
+ $this->ColorFlag=$cf;
}
- $this->TextColor=$tc;
- $this->ColorFlag=$cf;
-}
-function Header()
-{
- //To be implemented in your own inherited class
-}
+ function Header()
+ {
+ //To be implemented in your own inherited class
+ }
-function Footer()
-{
- //To be implemented in your own inherited class
-}
+ function Footer()
+ {
+ //To be implemented in your own inherited class
+ }
-function PageNo()
-{
- //Get current page number
- return $this->page;
-}
+ function PageNo()
+ {
+ //Get current page number
+ return $this->page;
+ }
-function SetDrawColor($r,$g=-1,$b=-1)
-{
- //Set color for all stroking operations
- if(($r==0 && $g==0 && $b==0) || $g==-1)
- $this->DrawColor=sprintf('%.3f G',$r/255);
- else
- $this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
- if($this->page>0)
+ function SetDrawColor($r, $g=null, $b=null)
+ {
+ //Set color for all stroking operations
+ if(($r==0 && $g==0 && $b==0) || $g===null)
+ $this->DrawColor=sprintf('%.3F G',$r/255);
+ else
+ $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
+ if($this->page>0)
$this->_out($this->DrawColor);
-}
+ }
-function SetFillColor($r,$g=-1,$b=-1)
-{
- //Set color for all filling operations
- if(($r==0 && $g==0 && $b==0) || $g==-1)
- $this->FillColor=sprintf('%.3f g',$r/255);
- else
- $this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
- $this->ColorFlag=($this->FillColor!=$this->TextColor);
- if($this->page>0)
+ function SetFillColor($r, $g=null, $b=null)
+ {
+ //Set color for all filling operations
+ if(($r==0 && $g==0 && $b==0) || $g===null)
+ $this->FillColor=sprintf('%.3F g',$r/255);
+ else
+ $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
+ $this->ColorFlag=($this->FillColor!=$this->TextColor);
+ if($this->page>0)
$this->_out($this->FillColor);
-}
+ }
-function SetTextColor($r,$g=-1,$b=-1)
-{
- //Set color for text
- if(($r==0 && $g==0 && $b==0) || $g==-1)
- $this->TextColor=sprintf('%.3f g',$r/255);
- else
- $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
- $this->ColorFlag=($this->FillColor!=$this->TextColor);
-}
+ function SetTextColor($r, $g=null, $b=null)
+ {
+ //Set color for text
+ if(($r==0 && $g==0 && $b==0) || $g===null)
+ $this->TextColor=sprintf('%.3F g',$r/255);
+ else
+ $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
+ $this->ColorFlag=($this->FillColor!=$this->TextColor);
+ }
-function GetStringWidth($s)
-{
- //Get width of a string in the current font
- $s=(string)$s;
- $cw=&$this->CurrentFont['cw'];
- $w=0;
- $l=strlen($s);
- for($i=0;$i<$l;$i++)
- $w+=$cw[$s{$i}];
- return $w*$this->FontSize/1000;
-}
+ function GetStringWidth($s)
+ {
+ //Get width of a string in the current font
+ $s=(string)$s;
+ $cw=&$this->CurrentFont['cw'];
+ $w=0;
+ $l=strlen($s);
+ for($i=0;$i<$l;$i++)
+ $w+=$cw[$s[$i]];
+ return $w*$this->FontSize/1000;
+ }
-function SetLineWidth($width)
-{
- //Set line width
- $this->LineWidth=$width;
- if($this->page>0)
- $this->_out(sprintf('%.2f w',$width*$this->k));
-}
+ function SetLineWidth($width)
+ {
+ //Set line width
+ $this->LineWidth=$width;
+ if($this->page>0)
+ $this->_out(sprintf('%.2F w',$width*$this->k));
+ }
-function Line($x1,$y1,$x2,$y2)
-{
- //Draw a line
- $this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
-}
+ function Line($x1, $y1, $x2, $y2)
+ {
+ //Draw a line
+ $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
+ }
-function Rect($x,$y,$w,$h,$style='')
-{
- //Draw a rectangle
- if($style=='F')
+ function Rect($x, $y, $w, $h, $style='')
+ {
+ //Draw a rectangle
+ if($style=='F')
$op='f';
- elseif($style=='FD' || $style=='DF')
+ elseif($style=='FD' || $style=='DF')
$op='B';
- else
+ else
$op='S';
- $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
-}
+ $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
+ }
-function AddFont($family,$style='',$file='')
-{
- //Add a TrueType or Type1 font
- $family=strtolower($family);
- if($file=='')
+ function AddFont($family, $style='', $file='')
+ {
+ //Add a TrueType or Type1 font
+ $family=strtolower($family);
+ if($file=='')
$file=str_replace(' ','',$family).strtolower($style).'.php';
- if($family=='arial')
+ if($family=='arial')
$family='helvetica';
- $style=strtoupper($style);
- if($style=='IB')
+ $style=strtoupper($style);
+ if($style=='IB')
$style='BI';
- $fontkey=$family.$style;
- if(isset($this->fonts[$fontkey]))
- $this->Error('Font already added: '.$family.' '.$style);
- include($this->_getfontpath().$file);
- if(!isset($name))
+ $fontkey=$family.$style;
+ if(isset($this->fonts[$fontkey]))
+ return;
+ include($this->_getfontpath().$file);
+ if(!isset($name))
$this->Error('Could not include font definition file');
- $i=count($this->fonts)+1;
- $this->fonts[$fontkey]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file);
- if($diff)
- {
- //Search existing encodings
- $d=0;
- $nb=count($this->diffs);
- for($i=1;$i<=$nb;$i++)
+ $i=count($this->fonts)+1;
+ $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
+ if($diff)
{
- if($this->diffs[$i]==$diff)
+ //Search existing encodings
+ $d=0;
+ $nb=count($this->diffs);
+ for($i=1;$i<=$nb;$i++)
{
- $d=$i;
- break;
+ if($this->diffs[$i]==$diff)
+ {
+ $d=$i;
+ break;
+ }
+ }
+ if($d==0)
+ {
+ $d=$nb+1;
+ $this->diffs[$d]=$diff;
}
+ $this->fonts[$fontkey]['diff']=$d;
}
- if($d==0)
+ if($file)
{
- $d=$nb+1;
- $this->diffs[$d]=$diff;
- }
- $this->fonts[$fontkey]['diff']=$d;
- }
- if($file)
- {
- if($type=='TrueType')
+ if($type=='TrueType')
$this->FontFiles[$file]=array('length1'=>$originalsize);
- else
- $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
+ else
+ $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
+ }
}
-}
-function SetFont($family,$style='',$size=0)
-{
- //Select a font; size given in points
- global $fpdf_charwidths;
+ function SetFont($family, $style='', $size=0)
+ {
+ //Select a font; size given in points
+ global $fpdf_charwidths;
- $family=strtolower($family);
- if($family=='')
+ $family=strtolower($family);
+ if($family=='')
$family=$this->FontFamily;
- if($family=='arial')
+ if($family=='arial')
$family='helvetica';
- elseif($family=='symbol' || $family=='zapfdingbats')
+ elseif($family=='symbol' || $family=='zapfdingbats')
$style='';
- $style=strtoupper($style);
- if(strpos($style,'U')!==false)
- {
- $this->underline=true;
- $style=str_replace('U','',$style);
- }
- else
+ $style=strtoupper($style);
+ if(strpos($style,'U')!==false)
+ {
+ $this->underline=true;
+ $style=str_replace('U','',$style);
+ }
+ else
$this->underline=false;
- if($style=='IB')
+ if($style=='IB')
$style='BI';
- if($size==0)
+ if($size==0)
$size=$this->FontSizePt;
- //Test if font is already selected
- if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
+ //Test if font is already selected
+ if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
return;
- //Test if used for the first time
- $fontkey=$family.$style;
- if(!isset($this->fonts[$fontkey]))
- {
- //Check if one of the standard fonts
- if(isset($this->CoreFonts[$fontkey]))
+ //Test if used for the first time
+ $fontkey=$family.$style;
+ if(!isset($this->fonts[$fontkey]))
{
- if(!isset($fpdf_charwidths[$fontkey]))
+ //Check if one of the standard fonts
+ if(isset($this->CoreFonts[$fontkey]))
{
- //Load metric file
- $file=$family;
- if($family=='times' || $family=='helvetica')
- $file.=strtolower($style);
- include($this->_getfontpath().$file.'.php');
if(!isset($fpdf_charwidths[$fontkey]))
+ {
+ //Load metric file
+ $file=$family;
+ if($family=='times' || $family=='helvetica')
+ $file.=strtolower($style);
+ include($this->_getfontpath().$file.'.php');
+ if(!isset($fpdf_charwidths[$fontkey]))
$this->Error('Could not include font metric file');
+ }
+ $i=count($this->fonts)+1;
+ $name=$this->CoreFonts[$fontkey];
+ $cw=$fpdf_charwidths[$fontkey];
+ $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
}
- $i=count($this->fonts)+1;
- $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
- }
- else
+ else
$this->Error('Undefined font: '.$family.' '.$style);
+ }
+ //Select it
+ $this->FontFamily=$family;
+ $this->FontStyle=$style;
+ $this->FontSizePt=$size;
+ $this->FontSize=$size/$this->k;
+ $this->CurrentFont=&$this->fonts[$fontkey];
+ if($this->page>0)
+ $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
}
- //Select it
- $this->FontFamily=$family;
- $this->FontStyle=$style;
- $this->FontSizePt=$size;
- $this->FontSize=$size/$this->k;
- $this->CurrentFont=&$this->fonts[$fontkey];
- if($this->page>0)
- $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
-}
-function SetFontSize($size)
-{
- //Set font size in points
- if($this->FontSizePt==$size)
+ function SetFontSize($size)
+ {
+ //Set font size in points
+ if($this->FontSizePt==$size)
return;
- $this->FontSizePt=$size;
- $this->FontSize=$size/$this->k;
- if($this->page>0)
- $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
-}
+ $this->FontSizePt=$size;
+ $this->FontSize=$size/$this->k;
+ if($this->page>0)
+ $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
+ }
-function AddLink()
-{
- //Create a new internal link
- $n=count($this->links)+1;
- $this->links[$n]=array(0,0);
- return $n;
-}
+ function AddLink()
+ {
+ //Create a new internal link
+ $n=count($this->links)+1;
+ $this->links[$n]=array(0, 0);
+ return $n;
+ }
-function SetLink($link,$y=0,$page=-1)
-{
- //Set destination of internal link
- if($y==-1)
+ function SetLink($link, $y=0, $page=-1)
+ {
+ //Set destination of internal link
+ if($y==-1)
$y=$this->y;
- if($page==-1)
+ if($page==-1)
$page=$this->page;
- $this->links[$link]=array($page,$y);
-}
+ $this->links[$link]=array($page, $y);
+ }
-function Link($x,$y,$w,$h,$link)
-{
- //Put a link on the page
- $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link);
-}
+ function Link($x, $y, $w, $h, $link)
+ {
+ //Put a link on the page
+ $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
+ }
-function Text($x,$y,$txt)
-{
- //Output a string
- $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
- if($this->underline && $txt!='')
+ function Text($x, $y, $txt)
+ {
+ //Output a string
+ $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
+ if($this->underline && $txt!='')
$s.=' '.$this->_dounderline($x,$y,$txt);
- if($this->ColorFlag)
+ if($this->ColorFlag)
$s='q '.$this->TextColor.' '.$s.' Q';
- $this->_out($s);
-}
+ $this->_out($s);
+ }
-function AcceptPageBreak()
-{
- //Accept automatic page break or not
- return $this->AutoPageBreak;
-}
+ function AcceptPageBreak()
+ {
+ //Accept automatic page break or not
+ return $this->AutoPageBreak;
+ }
-function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
-{
- //Output a cell
- $k=$this->k;
- if($this->y+$h>$this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak())
+ function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
- //Automatic page break
- $x=$this->x;
- $ws=$this->ws;
- if($ws>0)
- {
- $this->ws=0;
- $this->_out('0 Tw');
- }
- $this->AddPage($this->CurOrientation);
- $this->x=$x;
- if($ws>0)
+ //Output a cell
+ $k=$this->k;
+ if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
{
- $this->ws=$ws;
- $this->_out(sprintf('%.3f Tw',$ws*$k));
+ //Automatic page break
+ $x=$this->x;
+ $ws=$this->ws;
+ if($ws>0)
+ {
+ $this->ws=0;
+ $this->_out('0 Tw');
+ }
+ $this->AddPage($this->CurOrientation,$this->CurPageFormat);
+ $this->x=$x;
+ if($ws>0)
+ {
+ $this->ws=$ws;
+ $this->_out(sprintf('%.3F Tw',$ws*$k));
+ }
}
- }
- if($w==0)
+ if($w==0)
$w=$this->w-$this->rMargin-$this->x;
- $s='';
- if($fill==1 || $border==1)
- {
- if($fill==1)
+ $s='';
+ if($fill || $border==1)
+ {
+ if($fill)
$op=($border==1) ? 'B' : 'f';
- else
+ else
$op='S';
- $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
- }
- if(is_string($border))
- {
- $x=$this->x;
- $y=$this->y;
- if(strpos($border,'L')!==false)
- $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
- if(strpos($border,'T')!==false)
- $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
- if(strpos($border,'R')!==false)
- $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
- if(strpos($border,'B')!==false)
- $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
- }
- if($txt!=='')
- {
- if($align=='R')
+ $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
+ }
+ if(is_string($border))
+ {
+ $x=$this->x;
+ $y=$this->y;
+ if(strpos($border,'L')!==false)
+ $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
+ if(strpos($border,'T')!==false)
+ $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
+ if(strpos($border,'R')!==false)
+ $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
+ if(strpos($border,'B')!==false)
+ $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
+ }
+ if($txt!=='')
+ {
+ if($align=='R')
$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
- elseif($align=='C')
+ elseif($align=='C')
$dx=($w-$this->GetStringWidth($txt))/2;
- else
+ else
$dx=$this->cMargin;
- if($this->ColorFlag)
+ if($this->ColorFlag)
$s.='q '.$this->TextColor.' ';
- $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
- $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
- if($this->underline)
+ $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
+ $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
+ if($this->underline)
$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
- if($this->ColorFlag)
+ if($this->ColorFlag)
$s.=' Q';
- if($link)
+ if($link)
$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
- }
- if($s)
+ }
+ if($s)
$this->_out($s);
- $this->lasth=$h;
- if($ln>0)
- {
- //Go to next line
- $this->y+=$h;
- if($ln==1)
+ $this->lasth=$h;
+ if($ln>0)
+ {
+ //Go to next line
+ $this->y+=$h;
+ if($ln==1)
$this->x=$this->lMargin;
- }
- else
+ }
+ else
$this->x+=$w;
-}
+ }
-function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
-{
- //Output text with automatic or explicit line breaks
- $cw=&$this->CurrentFont['cw'];
- if($w==0)
+ function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
+ {
+ //Output text with automatic or explicit line breaks
+ $cw=&$this->CurrentFont['cw'];
+ if($w==0)
$w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- $s=str_replace("\r",'',$txt);
- $nb=strlen($s);
- if($nb>0 && $s[$nb-1]=="\n")
+ $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
+ $s=str_replace("\r",'',$txt);
+ $nb=strlen($s);
+ if($nb>0 && $s[$nb-1]=="\n")
$nb--;
- $b=0;
- if($border)
- {
- if($border==1)
+ $b=0;
+ if($border)
{
- $border='LTRB';
- $b='LRT';
- $b2='LR';
- }
- else
- {
- $b2='';
- if(strpos($border,'L')!==false)
+ if($border==1)
+ {
+ $border='LTRB';
+ $b='LRT';
+ $b2='LR';
+ }
+ else
+ {
+ $b2='';
+ if(strpos($border,'L')!==false)
$b2.='L';
- if(strpos($border,'R')!==false)
+ if(strpos($border,'R')!==false)
$b2.='R';
- $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
- }
- }
- $sep=-1;
- $i=0;
- $j=0;
- $l=0;
- $ns=0;
- $nl=1;
- while($i<$nb)
- {
- //Get next character
- $c=$s{$i};
- if($c=="\n")
- {
- //Explicit line break
- if($this->ws>0)
- {
- $this->ws=0;
- $this->_out('0 Tw');
+ $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
}
- $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
- $i++;
- $sep=-1;
- $j=$i;
- $l=0;
- $ns=0;
- $nl++;
- if($border && $nl==2)
- $b=$b2;
- continue;
- }
- if($c==' ')
- {
- $sep=$i;
- $ls=$l;
- $ns++;
}
- $l+=$cw[$c];
- if($l>$wmax)
+ $sep=-1;
+ $i=0;
+ $j=0;
+ $l=0;
+ $ns=0;
+ $nl=1;
+ while($i<$nb)
{
- //Automatic line break
- if($sep==-1)
+ //Get next character
+ $c=$s[$i];
+ if($c=="\n")
{
- if($i==$j)
- $i++;
+ //Explicit line break
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
+ $i++;
+ $sep=-1;
+ $j=$i;
+ $l=0;
+ $ns=0;
+ $nl++;
+ if($border && $nl==2)
+ $b=$b2;
+ continue;
}
- else
+ if($c==' ')
{
- if($align=='J')
+ $sep=$i;
+ $ls=$l;
+ $ns++;
+ }
+ $l+=$cw[$c];
+ if($l>$wmax)
+ {
+ //Automatic line break
+ if($sep==-1)
{
- $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
- $this->_out(sprintf('%.3f Tw',$this->ws*$this->k));
+ if($i==$j)
+ $i++;
+ if($this->ws>0)
+ {
+ $this->ws=0;
+ $this->_out('0 Tw');
+ }
+ $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
}
- $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
- $i=$sep+1;
- }
- $sep=-1;
- $j=$i;
- $l=0;
- $ns=0;
- $nl++;
- if($border && $nl==2)
+ else
+ {
+ if($align=='J')
+ {
+ $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
+ $this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
+ }
+ $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
+ $i=$sep+1;
+ }
+ $sep=-1;
+ $j=$i;
+ $l=0;
+ $ns=0;
+ $nl++;
+ if($border && $nl==2)
$b=$b2;
- }
- else
+ }
+ else
$i++;
- }
- //Last chunk
- if($this->ws>0)
- {
- $this->ws=0;
- $this->_out('0 Tw');
- }
- if($border && strpos($border,'B')!==false)
+ }
+ //Last chunk
+ if($this->ws>0)
+ {
+ $this->ws=0;
+ $this->_out('0 Tw');
+ }
+ if($border && strpos($border,'B')!==false)
$b.='B';
- $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
- $this->x=$this->lMargin;
-}
+ $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
+ $this->x=$this->lMargin;
+ }
-function Write($h,$txt,$link='')
-{
- //Output text in flowing mode
- $cw=&$this->CurrentFont['cw'];
- $w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- $s=str_replace("\r",'',$txt);
- $nb=strlen($s);
- $sep=-1;
- $i=0;
- $j=0;
- $l=0;
- $nl=1;
- while($i<$nb)
- {
- //Get next character
- $c=$s{$i};
- if($c=="\n")
+ function Write($h, $txt, $link='')
+ {
+ //Output text in flowing mode
+ $cw=&$this->CurrentFont['cw'];
+ $w=$this->w-$this->rMargin-$this->x;
+ $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
+ $s=str_replace("\r",'',$txt);
+ $nb=strlen($s);
+ $sep=-1;
+ $i=0;
+ $j=0;
+ $l=0;
+ $nl=1;
+ while($i<$nb)
{
- //Explicit line break
- $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
- $i++;
- $sep=-1;
- $j=$i;
- $l=0;
- if($nl==1)
+ //Get next character
+ $c=$s[$i];
+ if($c=="\n")
{
- $this->x=$this->lMargin;
- $w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
+ //Explicit line break
+ $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
+ $i++;
+ $sep=-1;
+ $j=$i;
+ $l=0;
+ if($nl==1)
+ {
+ $this->x=$this->lMargin;
+ $w=$this->w-$this->rMargin-$this->x;
+ $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
+ }
+ $nl++;
+ continue;
}
- $nl++;
- continue;
- }
- if($c==' ')
+ if($c==' ')
$sep=$i;
- $l+=$cw[$c];
- if($l>$wmax)
- {
- //Automatic line break
- if($sep==-1)
+ $l+=$cw[$c];
+ if($l>$wmax)
{
- if($this->x>$this->lMargin)
+ //Automatic line break
+ if($sep==-1)
+ {
+ if($this->x>$this->lMargin)
+ {
+ //Move to next line
+ $this->x=$this->lMargin;
+ $this->y+=$h;
+ $w=$this->w-$this->rMargin-$this->x;
+ $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
+ $i++;
+ $nl++;
+ continue;
+ }
+ if($i==$j)
+ $i++;
+ $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
+ }
+ else
+ {
+ $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
+ $i=$sep+1;
+ }
+ $sep=-1;
+ $j=$i;
+ $l=0;
+ if($nl==1)
{
- //Move to next line
$this->x=$this->lMargin;
- $this->y+=$h;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- $i++;
- $nl++;
- continue;
}
- if($i==$j)
- $i++;
- $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
+ $nl++;
}
else
- {
- $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
- $i=$sep+1;
- }
- $sep=-1;
- $j=$i;
- $l=0;
- if($nl==1)
- {
- $this->x=$this->lMargin;
- $w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- }
- $nl++;
+ $i++;
}
+ //Last chunk
+ if($i!=$j)
+ $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
+ }
+
+ function Ln($h=null)
+ {
+ //Line feed; default value is last cell height
+ $this->x=$this->lMargin;
+ if($h===null)
+ $this->y+=$this->lasth;
else
- $i++;
+ $this->y+=$h;
}
- //Last chunk
- if($i!=$j)
- $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
-}
-function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
-{
- //Put an image on the page
- if(!isset($this->images[$file]))
+ function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
{
- //First use of image, get info
- if($type=='')
+ //Put an image on the page
+ if(!isset($this->images[$file]))
{
- $pos=strrpos($file,'.');
- if(!$pos)
+ //First use of this image, get info
+ if($type=='')
+ {
+ $pos=strrpos($file,'.');
+ if(!$pos)
$this->Error('Image file has no extension and no type was specified: '.$file);
- $type=substr($file,$pos+1);
- }
- $type=strtolower($type);
- $mqr=get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
- if($type=='jpg' || $type=='jpeg')
- $info=$this->_parsejpg($file);
- elseif($type=='png')
- $info=$this->_parsepng($file);
- else
- {
- //Allow for additional formats
+ $type=substr($file,$pos+1);
+ }
+ $type=strtolower($type);
+ if($type=='jpeg')
+ $type='jpg';
$mtd='_parse'.$type;
if(!method_exists($this,$mtd))
- $this->Error('Unsupported image type: '.$type);
+ $this->Error('Unsupported image type: '.$type);
$info=$this->$mtd($file);
+ $info['i']=count($this->images)+1;
+ $this->images[$file]=$info;
}
- set_magic_quotes_runtime($mqr);
- $info['i']=count($this->images)+1;
- $this->images[$file]=$info;
- }
- else
+ else
$info=$this->images[$file];
- //Automatic width and height calculation if needed
- if($w==0 && $h==0)
- {
- //Put image at 72 dpi
- $w=$info['w']/$this->k;
- $h=$info['h']/$this->k;
- }
- if($w==0)
+ //Automatic width and height calculation if needed
+ if($w==0 && $h==0)
+ {
+ //Put image at 72 dpi
+ $w=$info['w']/$this->k;
+ $h=$info['h']/$this->k;
+ }
+ elseif($w==0)
$w=$h*$info['w']/$info['h'];
- if($h==0)
+ elseif($h==0)
$h=$w*$info['h']/$info['w'];
- $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
- if($link)
+ //Flowing mode
+ if($y===null)
+ {
+ if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
+ {
+ //Automatic page break
+ $x2=$this->x;
+ $this->AddPage($this->CurOrientation,$this->CurPageFormat);
+ $this->x=$x2;
+ }
+ $y=$this->y;
+ $this->y+=$h;
+ }
+ if($x===null)
+ $x=$this->x;
+ $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
+ if($link)
$this->Link($x,$y,$w,$h,$link);
-}
-
-function Ln($h='')
-{
- //Line feed; default value is last cell height
- $this->x=$this->lMargin;
- if(is_string($h))
- $this->y+=$this->lasth;
- else
- $this->y+=$h;
-}
+ }
-function GetX()
-{
- //Get x position
- return $this->x;
-}
+ function GetX()
+ {
+ //Get x position
+ return $this->x;
+ }
-function SetX($x)
-{
- //Set x position
- if($x>=0)
+ function SetX($x)
+ {
+ //Set x position
+ if($x>=0)
$this->x=$x;
- else
+ else
$this->x=$this->w+$x;
-}
+ }
-function GetY()
-{
- //Get y position
- return $this->y;
-}
+ function GetY()
+ {
+ //Get y position
+ return $this->y;
+ }
-function SetY($y)
-{
- //Set y position and reset x
- $this->x=$this->lMargin;
- if($y>=0)
+ function SetY($y)
+ {
+ //Set y position and reset x
+ $this->x=$this->lMargin;
+ if($y>=0)
$this->y=$y;
- else
+ else
$this->y=$this->h+$y;
-}
+ }
-function SetXY($x,$y)
-{
- //Set x and y positions
- $this->SetY($y);
- $this->SetX($x);
-}
+ function SetXY($x, $y)
+ {
+ //Set x and y positions
+ $this->SetY($y);
+ $this->SetX($x);
+ }
-function Output($name='',$dest='')
-{
- //Output PDF to some destination
- //Finish document if necessary
- if($this->state<3)
- $this->Close();
- //Normalize parameters
- if(is_bool($dest))
- $dest=$dest ? 'D' : 'F';
- $dest=strtoupper($dest);
- if($dest=='')
+ function Output($name='', $dest='')
{
- if($name=='')
+ //Output PDF to some destination
+ if($this->state<3)
+ $this->Close();
+ $dest=strtoupper($dest);
+ if($dest=='')
{
- $name='doc.pdf';
- $dest='I';
- }
- else
+ if($name=='')
+ {
+ $name='doc.pdf';
+ $dest='I';
+ }
+ else
$dest='F';
- }
- switch($dest)
- {
- case 'I':
- //Send to standard output
- if(ob_get_contents())
+ }
+ switch($dest)
+ {
+ case 'I':
+ //Send to standard output
+ if(ob_get_length())
$this->Error('Some data has already been output, can\'t send PDF file');
- if(php_sapi_name()!='cli')
- {
- //We send to a browser
- header('Content-Type: application/pdf');
+ if(php_sapi_name()!='cli')
+ {
+ //We send to a browser
+ header('Content-Type: application/pdf');
+ if(headers_sent())
+ $this->Error('Some data has already been output, can\'t send PDF file');
+ header('Content-Length: '.strlen($this->buffer));
+ header('Content-Disposition: inline; filename="'.$name.'"');
+ header('Cache-Control: private, max-age=0, must-revalidate');
+ header('Pragma: public');
+ ini_set('zlib.output_compression','0');
+ }
+ echo $this->buffer;
+ break;
+ case 'D':
+ //Download file
+ if(ob_get_length())
+ $this->Error('Some data has already been output, can\'t send PDF file');
+ header('Content-Type: application/x-download');
if(headers_sent())
- $this->Error('Some data has already been output to browser, can\'t send PDF file');
- header('Content-Length: '.strlen($this->buffer));
- header('Content-disposition: inline; filename="'.$name.'"');
- }
- echo $this->buffer;
- break;
- case 'D':
- //Download file
- if(ob_get_contents())
$this->Error('Some data has already been output, can\'t send PDF file');
- if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
- header('Content-Type: application/force-download');
- else
- header('Content-Type: application/octet-stream');
- if(headers_sent())
- $this->Error('Some data has already been output to browser, can\'t send PDF file');
- header('Content-Length: '.strlen($this->buffer));
- header('Content-disposition: attachment; filename="'.$name.'"');
- echo $this->buffer;
- break;
- case 'F':
- //Save to local file
- $f=fopen($name,'wb');
- if(!$f)
+ header('Content-Length: '.strlen($this->buffer));
+ header('Content-Disposition: attachment; filename="'.$name.'"');
+ header('Cache-Control: private, max-age=0, must-revalidate');
+ header('Pragma: public');
+ ini_set('zlib.output_compression','0');
+ echo $this->buffer;
+ break;
+ case 'F':
+ //Save to local file
+ $f=fopen($name,'wb');
+ if(!$f)
$this->Error('Unable to create output file: '.$name);
- fwrite($f,$this->buffer,strlen($this->buffer));
- fclose($f);
- break;
- case 'S':
- //Return as a string
- return $this->buffer;
- default:
- $this->Error('Incorrect output destination: '.$dest);
+ fwrite($f,$this->buffer,strlen($this->buffer));
+ fclose($f);
+ break;
+ case 'S':
+ //Return as a string
+ return $this->buffer;
+ default:
+ $this->Error('Incorrect output destination: '.$dest);
+ }
+ return '';
}
- return '';
-}
-/*******************************************************************************
-* *
-* Protected methods *
-* *
-*******************************************************************************/
-function _dochecks()
-{
- //Check for locale-related bug
- if(1.1==1)
- $this->Error('Don\'t alter the locale before including class file');
- //Check for decimal separator
- if(sprintf('%.1f',1.0)!='1.0')
- setlocale(LC_NUMERIC,'C');
-}
+ /*******************************************************************************
+ * *
+ * Protected methods *
+ * *
+ *******************************************************************************/
+ function _dochecks()
+ {
+ //Check availability of %F
+ if(sprintf('%.1F',1.0)!='1.0')
+ $this->Error('This version of PHP is not supported');
+ //Check mbstring overloading
+ if(ini_get('mbstring.func_overload') & 2)
+ $this->Error('mbstring overloading must be disabled');
+ //Disable runtime magic quotes
+ if(get_magic_quotes_runtime())
+ @set_magic_quotes_runtime(0);
+ }
-function _getfontpath()
-{
- if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
+ function _getpageformat($format)
+ {
+ $format=strtolower($format);
+ if(!isset($this->PageFormats[$format]))
+ $this->Error('Unknown page format: '.$format);
+ $a=$this->PageFormats[$format];
+ return array($a[0]/$this->k, $a[1]/$this->k);
+ }
+
+ function _getfontpath()
+ {
+ if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
- return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
-}
+ return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
+ }
-function _putpages()
-{
- $nb=$this->page;
- if(!empty($this->AliasNbPages))
+ function _beginpage($orientation, $format)
{
- //Replace number of pages
- for($n=1;$n<=$nb;$n++)
- $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
+ $this->page++;
+ $this->pages[$this->page]='';
+ $this->state=2;
+ $this->x=$this->lMargin;
+ $this->y=$this->tMargin;
+ $this->FontFamily='';
+ //Check page size
+ if($orientation=='')
+ $orientation=$this->DefOrientation;
+ else
+ $orientation=strtoupper($orientation[0]);
+ if($format=='')
+ $format=$this->DefPageFormat;
+ else
+ {
+ if(is_string($format))
+ $format=$this->_getpageformat($format);
+ }
+ if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
+ {
+ //New size
+ if($orientation=='P')
+ {
+ $this->w=$format[0];
+ $this->h=$format[1];
+ }
+ else
+ {
+ $this->w=$format[1];
+ $this->h=$format[0];
+ }
+ $this->wPt=$this->w*$this->k;
+ $this->hPt=$this->h*$this->k;
+ $this->PageBreakTrigger=$this->h-$this->bMargin;
+ $this->CurOrientation=$orientation;
+ $this->CurPageFormat=$format;
+ }
+ if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
+ $this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
+ }
+
+ function _endpage()
+ {
+ $this->state=1;
}
- if($this->DefOrientation=='P')
+
+ function _escape($s)
{
- $wPt=$this->fwPt;
- $hPt=$this->fhPt;
+ //Escape special characters in strings
+ $s=str_replace('\\','\\\\',$s);
+ $s=str_replace('(','\\(',$s);
+ $s=str_replace(')','\\)',$s);
+ $s=str_replace("\r",'\\r',$s);
+ return $s;
}
- else
+
+ function _textstring($s)
{
- $wPt=$this->fhPt;
- $hPt=$this->fwPt;
+ //Format a text string
+ return '('.$this->_escape($s).')';
}
- $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
- for($n=1;$n<=$nb;$n++)
+
+ function _UTF8toUTF16($s)
{
- //Page
- $this->_newobj();
- $this->_out('<</Type /Page');
- $this->_out('/Parent 1 0 R');
- if(isset($this->OrientationChanges[$n]))
- $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
- $this->_out('/Resources 2 0 R');
- if(isset($this->PageLinks[$n]))
+ //Convert UTF-8 to UTF-16BE with BOM
+ $res="\xFE\xFF";
+ $nb=strlen($s);
+ $i=0;
+ while($i<$nb)
{
- //Links
- $annots='/Annots [';
- foreach($this->PageLinks[$n] as $pl)
+ $c1=ord($s[$i++]);
+ if($c1>=224)
{
- $rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
- $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
- if(is_string($pl[4]))
- $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
- else
- {
- $l=$this->links[$pl[4]];
- $h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
- $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
- }
+ //3-byte character
+ $c2=ord($s[$i++]);
+ $c3=ord($s[$i++]);
+ $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
+ $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
+ }
+ elseif($c1>=192)
+ {
+ //2-byte character
+ $c2=ord($s[$i++]);
+ $res.=chr(($c1 & 0x1C)>>2);
+ $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
+ }
+ else
+ {
+ //Single-byte character
+ $res.="\0".chr($c1);
}
- $this->_out($annots.']');
}
- $this->_out('/Contents '.($this->n+1).' 0 R>>');
- $this->_out('endobj');
- //Page content
- $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
- $this->_newobj();
- $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
- $this->_putstream($p);
- $this->_out('endobj');
+ return $res;
}
- //Pages root
- $this->offsets[1]=strlen($this->buffer);
- $this->_out('1 0 obj');
- $this->_out('<</Type /Pages');
- $kids='/Kids [';
- for($i=0;$i<$nb;$i++)
- $kids.=(3+2*$i).' 0 R ';
- $this->_out($kids.']');
- $this->_out('/Count '.$nb);
- $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
- $this->_out('>>');
- $this->_out('endobj');
-}
-function _putfonts()
-{
- $nf=$this->n;
- foreach($this->diffs as $diff)
+ function _dounderline($x, $y, $txt)
{
- //Encodings
- $this->_newobj();
- $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
- $this->_out('endobj');
+ //Underline text
+ $up=$this->CurrentFont['up'];
+ $ut=$this->CurrentFont['ut'];
+ $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
+ return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
}
- $mqr=get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
- foreach($this->FontFiles as $file=>$info)
+
+ function _parsejpg($file)
{
- //Font file embedding
- $this->_newobj();
- $this->FontFiles[$file]['n']=$this->n;
- $font='';
- $f=fopen($this->_getfontpath().$file,'rb',1);
- if(!$f)
- $this->Error('Font file not found');
+ //Extract info from a JPEG file
+ $a=GetImageSize($file);
+ if(!$a)
+ $this->Error('Missing or incorrect image file: '.$file);
+ if($a[2]!=2)
+ $this->Error('Not a JPEG file: '.$file);
+ if(!isset($a['channels']) || $a['channels']==3)
+ $colspace='DeviceRGB';
+ elseif($a['channels']==4)
+ $colspace='DeviceCMYK';
+ else
+ $colspace='DeviceGray';
+ $bpc=isset($a['bits']) ? $a['bits'] : 8;
+ //Read whole file
+ $f=fopen($file,'rb');
+ $data='';
while(!feof($f))
- $font.=fread($f,8192);
+ $data.=fread($f,8192);
fclose($f);
- $compressed=(substr($file,-2)=='.z');
- if(!$compressed && isset($info['length2']))
+ return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
+ }
+
+ function _parsepng($file)
+ {
+ //Extract info from a PNG file
+ $f=fopen($file,'rb');
+ if(!$f)
+ $this->Error('Can\'t open image file: '.$file);
+ //Check signature
+ if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
+ $this->Error('Not a PNG file: '.$file);
+ //Read header chunk
+ $this->_readstream($f,4);
+ if($this->_readstream($f,4)!='IHDR')
+ $this->Error('Incorrect PNG file: '.$file);
+ $w=$this->_readint($f);
+ $h=$this->_readint($f);
+ $bpc=ord($this->_readstream($f,1));
+ if($bpc>8)
+ $this->Error('16-bit depth not supported: '.$file);
+ $ct=ord($this->_readstream($f,1));
+ if($ct==0)
+ $colspace='DeviceGray';
+ elseif($ct==2)
+ $colspace='DeviceRGB';
+ elseif($ct==3)
+ $colspace='Indexed';
+ else
+ $this->Error('Alpha channel not supported: '.$file);
+ if(ord($this->_readstream($f,1))!=0)
+ $this->Error('Unknown compression method: '.$file);
+ if(ord($this->_readstream($f,1))!=0)
+ $this->Error('Unknown filter method: '.$file);
+ if(ord($this->_readstream($f,1))!=0)
+ $this->Error('Interlacing not supported: '.$file);
+ $this->_readstream($f,4);
+ $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
+ //Scan chunks looking for palette, transparency and image data
+ $pal='';
+ $trns='';
+ $data='';
+ do
{
- $header=(ord($font{0})==128);
- if($header)
+ $n=$this->_readint($f);
+ $type=$this->_readstream($f,4);
+ if($type=='PLTE')
+ {
+ //Read palette
+ $pal=$this->_readstream($f,$n);
+ $this->_readstream($f,4);
+ }
+ elseif($type=='tRNS')
{
- //Strip first binary header
- $font=substr($font,6);
+ //Read transparency info
+ $t=$this->_readstream($f,$n);
+ if($ct==0)
+ $trns=array(ord(substr($t,1,1)));
+ elseif($ct==2)
+ $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
+ else
+ {
+ $pos=strpos($t,chr(0));
+ if($pos!==false)
+ $trns=array($pos);
+ }
+ $this->_readstream($f,4);
}
- if($header && ord($font{$info['length1']})==128)
+ elseif($type=='IDAT')
{
- //Strip second binary header
- $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
+ //Read image data block
+ $data.=$this->_readstream($f,$n);
+ $this->_readstream($f,4);
}
+ elseif($type=='IEND')
+ break;
+ else
+ $this->_readstream($f,$n+4);
}
- $this->_out('<</Length '.strlen($font));
- if($compressed)
- $this->_out('/Filter /FlateDecode');
- $this->_out('/Length1 '.$info['length1']);
- if(isset($info['length2']))
- $this->_out('/Length2 '.$info['length2'].' /Length3 0');
+ while($n);
+ if($colspace=='Indexed' && empty($pal))
+ $this->Error('Missing palette in '.$file);
+ fclose($f);
+ return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
+ }
+
+ function _readstream($f, $n)
+ {
+ //Read n bytes from stream
+ $res='';
+ while($n>0 && !feof($f))
+ {
+ $s=fread($f,$n);
+ if($s===false)
+ $this->Error('Error while reading stream');
+ $n-=strlen($s);
+ $res.=$s;
+ }
+ if($n>0)
+ $this->Error('Unexpected end of stream');
+ return $res;
+ }
+
+ function _readint($f)
+ {
+ //Read a 4-byte integer from stream
+ $a=unpack('Ni',$this->_readstream($f,4));
+ return $a['i'];
+ }
+
+ function _parsegif($file)
+ {
+ //Extract info from a GIF file (via PNG conversion)
+ if(!function_exists('imagepng'))
+ $this->Error('GD extension is required for GIF support');
+ if(!function_exists('imagecreatefromgif'))
+ $this->Error('GD has no GIF read support');
+ $im=imagecreatefromgif($file);
+ if(!$im)
+ $this->Error('Missing or incorrect image file: '.$file);
+ imageinterlace($im,0);
+ $tmp=tempnam('.','gif');
+ if(!$tmp)
+ $this->Error('Unable to create a temporary file');
+ if(!imagepng($im,$tmp))
+ $this->Error('Error while saving to temporary file');
+ imagedestroy($im);
+ $info=$this->_parsepng($tmp);
+ unlink($tmp);
+ return $info;
+ }
+
+ function _newobj()
+ {
+ //Begin a new object
+ $this->n++;
+ $this->offsets[$this->n]=strlen($this->buffer);
+ $this->_out($this->n.' 0 obj');
+ }
+
+ function _putstream($s)
+ {
+ $this->_out('stream');
+ $this->_out($s);
+ $this->_out('endstream');
+ }
+
+ function _out($s)
+ {
+ //Add a line to the document
+ if($this->state==2)
+ $this->pages[$this->page].=$s."\n";
+ else
+ $this->buffer.=$s."\n";
+ }
+
+ function _putpages()
+ {
+ $nb=$this->page;
+ if(!empty($this->AliasNbPages))
+ {
+ //Replace number of pages
+ for($n=1;$n<=$nb;$n++)
+ $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
+ }
+ if($this->DefOrientation=='P')
+ {
+ $wPt=$this->DefPageFormat[0]*$this->k;
+ $hPt=$this->DefPageFormat[1]*$this->k;
+ }
+ else
+ {
+ $wPt=$this->DefPageFormat[1]*$this->k;
+ $hPt=$this->DefPageFormat[0]*$this->k;
+ }
+ $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
+ for($n=1;$n<=$nb;$n++)
+ {
+ //Page
+ $this->_newobj();
+ $this->_out('<</Type /Page');
+ $this->_out('/Parent 1 0 R');
+ if(isset($this->PageSizes[$n]))
+ $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
+ $this->_out('/Resources 2 0 R');
+ if(isset($this->PageLinks[$n]))
+ {
+ //Links
+ $annots='/Annots [';
+ foreach($this->PageLinks[$n] as $pl)
+ {
+ $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
+ $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
+ if(is_string($pl[4]))
+ $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
+ else
+ {
+ $l=$this->links[$pl[4]];
+ $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
+ $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
+ }
+ }
+ $this->_out($annots.']');
+ }
+ $this->_out('/Contents '.($this->n+1).' 0 R>>');
+ $this->_out('endobj');
+ //Page content
+ $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
+ $this->_newobj();
+ $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
+ $this->_putstream($p);
+ $this->_out('endobj');
+ }
+ //Pages root
+ $this->offsets[1]=strlen($this->buffer);
+ $this->_out('1 0 obj');
+ $this->_out('<</Type /Pages');
+ $kids='/Kids [';
+ for($i=0;$i<$nb;$i++)
+ $kids.=(3+2*$i).' 0 R ';
+ $this->_out($kids.']');
+ $this->_out('/Count '.$nb);
+ $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
$this->_out('>>');
- $this->_putstream($font);
$this->_out('endobj');
}
- set_magic_quotes_runtime($mqr);
- foreach($this->fonts as $k=>$font)
+
+ function _putfonts()
{
- //Font objects
- $this->fonts[$k]['n']=$this->n+1;
- $type=$font['type'];
- $name=$font['name'];
- if($type=='core')
+ $nf=$this->n;
+ foreach($this->diffs as $diff)
{
- //Standard font
+ //Encodings
$this->_newobj();
- $this->_out('<</Type /Font');
- $this->_out('/BaseFont /'.$name);
- $this->_out('/Subtype /Type1');
- if($name!='Symbol' && $name!='ZapfDingbats')
- $this->_out('/Encoding /WinAnsiEncoding');
- $this->_out('>>');
+ $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
$this->_out('endobj');
}
- elseif($type=='Type1' || $type=='TrueType')
+ foreach($this->FontFiles as $file=>$info)
{
- //Additional Type1 or TrueType font
+ //Font file embedding
$this->_newobj();
- $this->_out('<</Type /Font');
- $this->_out('/BaseFont /'.$name);
- $this->_out('/Subtype /'.$type);
- $this->_out('/FirstChar 32 /LastChar 255');
- $this->_out('/Widths '.($this->n+1).' 0 R');
- $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
- if($font['enc'])
+ $this->FontFiles[$file]['n']=$this->n;
+ $font='';
+ $f=fopen($this->_getfontpath().$file,'rb',1);
+ if(!$f)
+ $this->Error('Font file not found');
+ while(!feof($f))
+ $font.=fread($f,8192);
+ fclose($f);
+ $compressed=(substr($file,-2)=='.z');
+ if(!$compressed && isset($info['length2']))
{
- if(isset($font['diff']))
- $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
- else
- $this->_out('/Encoding /WinAnsiEncoding');
+ $header=(ord($font[0])==128);
+ if($header)
+ {
+ //Strip first binary header
+ $font=substr($font,6);
+ }
+ if($header && ord($font[$info['length1']])==128)
+ {
+ //Strip second binary header
+ $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
+ }
}
+ $this->_out('<</Length '.strlen($font));
+ if($compressed)
+ $this->_out('/Filter /FlateDecode');
+ $this->_out('/Length1 '.$info['length1']);
+ if(isset($info['length2']))
+ $this->_out('/Length2 '.$info['length2'].' /Length3 0');
$this->_out('>>');
+ $this->_putstream($font);
$this->_out('endobj');
- //Widths
- $this->_newobj();
- $cw=&$font['cw'];
- $s='[';
- for($i=32;$i<=255;$i++)
+ }
+ foreach($this->fonts as $k=>$font)
+ {
+ //Font objects
+ $this->fonts[$k]['n']=$this->n+1;
+ $type=$font['type'];
+ $name=$font['name'];
+ if($type=='core')
+ {
+ //Standard font
+ $this->_newobj();
+ $this->_out('<</Type /Font');
+ $this->_out('/BaseFont /'.$name);
+ $this->_out('/Subtype /Type1');
+ if($name!='Symbol' && $name!='ZapfDingbats')
+ $this->_out('/Encoding /WinAnsiEncoding');
+ $this->_out('>>');
+ $this->_out('endobj');
+ }
+ elseif($type=='Type1' || $type=='TrueType')
+ {
+ //Additional Type1 or TrueType font
+ $this->_newobj();
+ $this->_out('<</Type /Font');
+ $this->_out('/BaseFont /'.$name);
+ $this->_out('/Subtype /'.$type);
+ $this->_out('/FirstChar 32 /LastChar 255');
+ $this->_out('/Widths '.($this->n+1).' 0 R');
+ $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
+ if($font['enc'])
+ {
+ if(isset($font['diff']))
+ $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
+ else
+ $this->_out('/Encoding /WinAnsiEncoding');
+ }
+ $this->_out('>>');
+ $this->_out('endobj');
+ //Widths
+ $this->_newobj();
+ $cw=&$font['cw'];
+ $s='[';
+ for($i=32;$i<=255;$i++)
$s.=$cw[chr($i)].' ';
- $this->_out($s.']');
- $this->_out('endobj');
- //Descriptor
- $this->_newobj();
- $s='<</Type /FontDescriptor /FontName /'.$name;
- foreach($font['desc'] as $k=>$v)
+ $this->_out($s.']');
+ $this->_out('endobj');
+ //Descriptor
+ $this->_newobj();
+ $s='<</Type /FontDescriptor /FontName /'.$name;
+ foreach($font['desc'] as $k=>$v)
$s.=' /'.$k.' '.$v;
- $file=$font['file'];
- if($file)
+ $file=$font['file'];
+ if($file)
$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
- $this->_out($s.'>>');
- $this->_out('endobj');
- }
- else
- {
- //Allow for additional types
- $mtd='_put'.strtolower($type);
- if(!method_exists($this,$mtd))
+ $this->_out($s.'>>');
+ $this->_out('endobj');
+ }
+ else
+ {
+ //Allow for additional types
+ $mtd='_put'.strtolower($type);
+ if(!method_exists($this,$mtd))
$this->Error('Unsupported font type: '.$type);
- $this->$mtd($font);
+ $this->$mtd($font);
+ }
}
}
-}
-function _putimages()
-{
- $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
- reset($this->images);
- while(list($file,$info)=each($this->images))
+ function _putimages()
{
- $this->_newobj();
- $this->images[$file]['n']=$this->n;
- $this->_out('<</Type /XObject');
- $this->_out('/Subtype /Image');
- $this->_out('/Width '.$info['w']);
- $this->_out('/Height '.$info['h']);
- if($info['cs']=='Indexed')
- $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
- else
+ $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
+ reset($this->images);
+ while(list($file,$info)=each($this->images))
{
- $this->_out('/ColorSpace /'.$info['cs']);
- if($info['cs']=='DeviceCMYK')
+ $this->_newobj();
+ $this->images[$file]['n']=$this->n;
+ $this->_out('<</Type /XObject');
+ $this->_out('/Subtype /Image');
+ $this->_out('/Width '.$info['w']);
+ $this->_out('/Height '.$info['h']);
+ if($info['cs']=='Indexed')
+ $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
+ else
+ {
+ $this->_out('/ColorSpace /'.$info['cs']);
+ if($info['cs']=='DeviceCMYK')
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
- }
- $this->_out('/BitsPerComponent '.$info['bpc']);
- if(isset($info['f']))
+ }
+ $this->_out('/BitsPerComponent '.$info['bpc']);
+ if(isset($info['f']))
$this->_out('/Filter /'.$info['f']);
- if(isset($info['parms']))
+ if(isset($info['parms']))
$this->_out($info['parms']);
- if(isset($info['trns']) && is_array($info['trns']))
- {
- $trns='';
- for($i=0;$i<count($info['trns']);$i++)
+ if(isset($info['trns']) && is_array($info['trns']))
+ {
+ $trns='';
+ for($i=0;$i<count($info['trns']);$i++)
$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
- $this->_out('/Mask ['.$trns.']');
- }
- $this->_out('/Length '.strlen($info['data']).'>>');
- $this->_putstream($info['data']);
- unset($this->images[$file]['data']);
- $this->_out('endobj');
- //Palette
- if($info['cs']=='Indexed')
- {
- $this->_newobj();
- $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
- $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
- $this->_putstream($pal);
+ $this->_out('/Mask ['.$trns.']');
+ }
+ $this->_out('/Length '.strlen($info['data']).'>>');
+ $this->_putstream($info['data']);
+ unset($this->images[$file]['data']);
$this->_out('endobj');
+ //Palette
+ if($info['cs']=='Indexed')
+ {
+ $this->_newobj();
+ $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
+ $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
+ $this->_putstream($pal);
+ $this->_out('endobj');
+ }
}
}
-}
-function _putxobjectdict()
-{
- foreach($this->images as $image)
+ function _putxobjectdict()
+ {
+ foreach($this->images as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
-}
+ }
-function _putresourcedict()
-{
- $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
- $this->_out('/Font <<');
- foreach($this->fonts as $font)
+ function _putresourcedict()
+ {
+ $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
+ $this->_out('/Font <<');
+ foreach($this->fonts as $font)
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
- $this->_out('>>');
- $this->_out('/XObject <<');
- $this->_putxobjectdict();
- $this->_out('>>');
-}
+ $this->_out('>>');
+ $this->_out('/XObject <<');
+ $this->_putxobjectdict();
+ $this->_out('>>');
+ }
-function _putresources()
-{
- $this->_putfonts();
- $this->_putimages();
- //Resource dictionary
- $this->offsets[2]=strlen($this->buffer);
- $this->_out('2 0 obj');
- $this->_out('<<');
- $this->_putresourcedict();
- $this->_out('>>');
- $this->_out('endobj');
-}
+ function _putresources()
+ {
+ $this->_putfonts();
+ $this->_putimages();
+ //Resource dictionary
+ $this->offsets[2]=strlen($this->buffer);
+ $this->_out('2 0 obj');
+ $this->_out('<<');
+ $this->_putresourcedict();
+ $this->_out('>>');
+ $this->_out('endobj');
+ }
-function _putinfo()
-{
- $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
- if(!empty($this->title))
+ function _putinfo()
+ {
+ $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
+ if(!empty($this->title))
$this->_out('/Title '.$this->_textstring($this->title));
- if(!empty($this->subject))
+ if(!empty($this->subject))
$this->_out('/Subject '.$this->_textstring($this->subject));
- if(!empty($this->author))
+ if(!empty($this->author))
$this->_out('/Author '.$this->_textstring($this->author));
- if(!empty($this->keywords))
+ if(!empty($this->keywords))
$this->_out('/Keywords '.$this->_textstring($this->keywords));
- if(!empty($this->creator))
+ if(!empty($this->creator))
$this->_out('/Creator '.$this->_textstring($this->creator));
- $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
-}
+ $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
+ }
-function _putcatalog()
-{
- $this->_out('/Type /Catalog');
- $this->_out('/Pages 1 0 R');
- if($this->ZoomMode=='fullpage')
+ function _putcatalog()
+ {
+ $this->_out('/Type /Catalog');
+ $this->_out('/Pages 1 0 R');
+ if($this->ZoomMode=='fullpage')
$this->_out('/OpenAction [3 0 R /Fit]');
- elseif($this->ZoomMode=='fullwidth')
+ elseif($this->ZoomMode=='fullwidth')
$this->_out('/OpenAction [3 0 R /FitH null]');
- elseif($this->ZoomMode=='real')
+ elseif($this->ZoomMode=='real')
$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
- elseif(!is_string($this->ZoomMode))
+ elseif(!is_string($this->ZoomMode))
$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
- if($this->LayoutMode=='single')
+ if($this->LayoutMode=='single')
$this->_out('/PageLayout /SinglePage');
- elseif($this->LayoutMode=='continuous')
+ elseif($this->LayoutMode=='continuous')
$this->_out('/PageLayout /OneColumn');
- elseif($this->LayoutMode=='two')
+ elseif($this->LayoutMode=='two')
$this->_out('/PageLayout /TwoColumnLeft');
-}
-
-function _putheader()
-{
- $this->_out('%PDF-'.$this->PDFVersion);
-}
-
-function _puttrailer()
-{
- $this->_out('/Size '.($this->n+1));
- $this->_out('/Root '.$this->n.' 0 R');
- $this->_out('/Info '.($this->n-1).' 0 R');
-}
-
-function _enddoc()
-{
- $this->_putheader();
- $this->_putpages();
- $this->_putresources();
- //Info
- $this->_newobj();
- $this->_out('<<');
- $this->_putinfo();
- $this->_out('>>');
- $this->_out('endobj');
- //Catalog
- $this->_newobj();
- $this->_out('<<');
- $this->_putcatalog();
- $this->_out('>>');
- $this->_out('endobj');
- //Cross-ref
- $o=strlen($this->buffer);
- $this->_out('xref');
- $this->_out('0 '.($this->n+1));
- $this->_out('0000000000 65535 f ');
- for($i=1;$i<=$this->n;$i++)
- $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
- //Trailer
- $this->_out('trailer');
- $this->_out('<<');
- $this->_puttrailer();
- $this->_out('>>');
- $this->_out('startxref');
- $this->_out($o);
- $this->_out('%%EOF');
- $this->state=3;
-}
+ }
-function _beginpage($orientation)
-{
- $this->page++;
- $this->pages[$this->page]='';
- $this->state=2;
- $this->x=$this->lMargin;
- $this->y=$this->tMargin;
- $this->FontFamily='';
- //Page orientation
- if(!$orientation)
- $orientation=$this->DefOrientation;
- else
+ function _putheader()
{
- $orientation=strtoupper($orientation{0});
- if($orientation!=$this->DefOrientation)
- $this->OrientationChanges[$this->page]=true;
+ $this->_out('%PDF-'.$this->PDFVersion);
}
- if($orientation!=$this->CurOrientation)
+
+ function _puttrailer()
{
- //Change orientation
- if($orientation=='P')
- {
- $this->wPt=$this->fwPt;
- $this->hPt=$this->fhPt;
- $this->w=$this->fw;
- $this->h=$this->fh;
- }
- else
- {
- $this->wPt=$this->fhPt;
- $this->hPt=$this->fwPt;
- $this->w=$this->fh;
- $this->h=$this->fw;
- }
- $this->PageBreakTrigger=$this->h-$this->bMargin;
- $this->CurOrientation=$orientation;
+ $this->_out('/Size '.($this->n+1));
+ $this->_out('/Root '.$this->n.' 0 R');
+ $this->_out('/Info '.($this->n-1).' 0 R');
}
-}
-
-function _endpage()
-{
- //End of page contents
- $this->state=1;
-}
-
-function _newobj()
-{
- //Begin a new object
- $this->n++;
- $this->offsets[$this->n]=strlen($this->buffer);
- $this->_out($this->n.' 0 obj');
-}
-
-function _dounderline($x,$y,$txt)
-{
- //Underline text
- $up=$this->CurrentFont['up'];
- $ut=$this->CurrentFont['ut'];
- $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
- return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
-}
-
-function _parsejpg($file)
-{
- //Extract info from a JPEG file
- $a=GetImageSize($file);
- if(!$a)
- $this->Error('Missing or incorrect image file: '.$file);
- if($a[2]!=2)
- $this->Error('Not a JPEG file: '.$file);
- if(!isset($a['channels']) || $a['channels']==3)
- $colspace='DeviceRGB';
- elseif($a['channels']==4)
- $colspace='DeviceCMYK';
- else
- $colspace='DeviceGray';
- $bpc=isset($a['bits']) ? $a['bits'] : 8;
- //Read whole file
- $f=fopen($file,'rb');
- $data='';
- while(!feof($f))
- $data.=fread($f,4096);
- fclose($f);
- return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);
-}
-function _parsepng($file)
-{
- //Extract info from a PNG file
- $f=fopen($file,'rb');
- if(!$f)
- $this->Error('Can\'t open image file: '.$file);
- //Check signature
- if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
- $this->Error('Not a PNG file: '.$file);
- //Read header chunk
- fread($f,4);
- if(fread($f,4)!='IHDR')
- $this->Error('Incorrect PNG file: '.$file);
- $w=$this->_freadint($f);
- $h=$this->_freadint($f);
- $bpc=ord(fread($f,1));
- if($bpc>8)
- $this->Error('16-bit depth not supported: '.$file);
- $ct=ord(fread($f,1));
- if($ct==0)
- $colspace='DeviceGray';
- elseif($ct==2)
- $colspace='DeviceRGB';
- elseif($ct==3)
- $colspace='Indexed';
- else
- $this->Error('Alpha channel not supported: '.$file);
- if(ord(fread($f,1))!=0)
- $this->Error('Unknown compression method: '.$file);
- if(ord(fread($f,1))!=0)
- $this->Error('Unknown filter method: '.$file);
- if(ord(fread($f,1))!=0)
- $this->Error('Interlacing not supported: '.$file);
- fread($f,4);
- $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
- //Scan chunks looking for palette, transparency and image data
- $pal='';
- $trns='';
- $data='';
- do
- {
- $n=$this->_freadint($f);
- $type=fread($f,4);
- if($type=='PLTE')
- {
- //Read palette
- $pal=fread($f,$n);
- fread($f,4);
- }
- elseif($type=='tRNS')
- {
- //Read transparency info
- $t=fread($f,$n);
- if($ct==0)
- $trns=array(ord(substr($t,1,1)));
- elseif($ct==2)
- $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
- else
- {
- $pos=strpos($t,chr(0));
- if($pos!==false)
- $trns=array($pos);
- }
- fread($f,4);
- }
- elseif($type=='IDAT')
- {
- //Read image data block
- $data.=fread($f,$n);
- fread($f,4);
- }
- elseif($type=='IEND')
- break;
- else
- fread($f,$n+4);
+ function _enddoc()
+ {
+ $this->_putheader();
+ $this->_putpages();
+ $this->_putresources();
+ //Info
+ $this->_newobj();
+ $this->_out('<<');
+ $this->_putinfo();
+ $this->_out('>>');
+ $this->_out('endobj');
+ //Catalog
+ $this->_newobj();
+ $this->_out('<<');
+ $this->_putcatalog();
+ $this->_out('>>');
+ $this->_out('endobj');
+ //Cross-ref
+ $o=strlen($this->buffer);
+ $this->_out('xref');
+ $this->_out('0 '.($this->n+1));
+ $this->_out('0000000000 65535 f ');
+ for($i=1;$i<=$this->n;$i++)
+ $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
+ //Trailer
+ $this->_out('trailer');
+ $this->_out('<<');
+ $this->_puttrailer();
+ $this->_out('>>');
+ $this->_out('startxref');
+ $this->_out($o);
+ $this->_out('%%EOF');
+ $this->state=3;
}
- while($n);
- if($colspace=='Indexed' && empty($pal))
- $this->Error('Missing palette in '.$file);
- fclose($f);
- return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);
-}
-
-function _freadint($f)
-{
- //Read a 4-byte integer from file
- $a=unpack('Ni',fread($f,4));
- return $a['i'];
-}
-
-function _textstring($s)
-{
- //Format a text string
- return '('.$this->_escape($s).')';
-}
-
-function _escape($s)
-{
- //Add \ before \, ( and )
- return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s)));
-}
-
-function _putstream($s)
-{
- $this->_out('stream');
- $this->_out($s);
- $this->_out('endstream');
+ //End of class
}
-function _out($s)
-{
- //Add a line to the document
- if($this->state==2)
- $this->pages[$this->page].=$s."\n";
- else
- $this->buffer.=$s."\n";
-}
-//End of class
-}
-
-//Handle special IE contype request
-if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
-{
- header('Content-Type: application/pdf');
- exit;
-}
-
-}
?>