html2pdf.class.php 138 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672
  1. <?php
  2. /**
  3. * Logiciel : HTML2PDF
  4. *
  5. * Convertisseur HTML => PDF, utilise fpdf de Olivier PLATHEY
  6. * Distribu� sous la licence LGPL.
  7. *
  8. * @author Laurent MINGUET <webmaster@spipu.net>
  9. * @version 3.24 - 05/08/2009
  10. */
  11. /**
  12. * Author: Juan Carlos Ra�a.
  13. * forced to read first because another similar library (but different version) can be found elsewhere in the system
  14. */
  15. $configurationPearPath = $configuration['root_sys'].'/main/inc/lib/html2pdf';
  16. ini_set('include_path', $configurationPearPath);
  17. if (!defined('__CLASS_HTML2PDF__'))
  18. {
  19. define('__CLASS_HTML2PDF__', '3.24');
  20. // vous pouvez utiliser cette fonction de debug comme suit
  21. // pour voir le temps et la m�moire utilis�s (sous linux) pour la conversion :
  22. // echo HTML2PDFgetTimerDebug();
  23. // $html2pdf->WriteHTML($content);
  24. // echo HTML2PDFgetTimerDebug();
  25. function HTML2PDFgetTimerDebug($debug=false)
  26. {
  27. global $TIMER_ACTION_LAST;
  28. list($usec, $sec) = explode(" ", microtime());
  29. $time = (float)$sec + (float)$usec;
  30. $mem = HTML2PDFgetMem();
  31. if (!$TIMER_ACTION_LAST)
  32. {
  33. if ($debug) $ret = null;
  34. else $ret = 'Debug : init'."<br />\n";
  35. }
  36. else
  37. {
  38. $aff_time = $time-$TIMER_ACTION_LAST[0];
  39. $aff_mem = $mem;
  40. if ($debug) $ret = array($aff_time, $aff_mem);
  41. else $ret = 'Timer : '.number_format($aff_time, 3, '.', '').'s - Memory used '.$aff_mem.' Ko'."<br />\n";
  42. }
  43. $TIMER_ACTION_LAST = array($time, $mem);
  44. return $ret;
  45. }
  46. function HTML2PDFgetMem() { return function_exists('memory_get_usage') ? floor(memory_get_usage()/1024) : 0; }
  47. require_once(dirname(__FILE__).'/_mypdf/mypdf.class.php'); // classe mypdf d�riv� de fpdf de Olivier PLATHEY
  48. require_once(dirname(__FILE__).'/parsingHTML.class.php'); // classe de parsing HTML
  49. require_once(dirname(__FILE__).'/styleHTML.class.php'); // classe de gestion des styles
  50. global $HTML2PDF_TABLEAU; $HTML2PDF_TABLEAU = array(); // tableau global necessaire � la gestion des tables imbriqu�es
  51. class HTML2PDF
  52. {
  53. var $langue = 'fr'; // langue des messages
  54. var $sens = 'P'; // sens d'affichage Portrait ou Landscape
  55. var $format = 'A4'; // format de la page : A4, A3, ...
  56. var $background = array(); // informations sur le background
  57. var $testTDin1page = true; // activer le test de TD ne devant pas depasser une page
  58. var $style = null; // objet de style
  59. var $parsing = null; // objet de parsing
  60. var $parse_pos = 0; // position du parsing
  61. var $temp_pos = 0; // position temporaire pour multi tableau
  62. var $sub_html = null; // sous html
  63. var $sub_part = false; // indicateur de sous html
  64. var $isSubPart = false; // indique que le convertisseur courant est un sous html
  65. var $pdf = null; // objet PDF
  66. var $maxX = 0; // zone maxi X
  67. var $maxY = 0; // zone maxi Y
  68. var $FirstPage = true; // premier page
  69. var $defaultLeft = 0; // marges par default de la page
  70. var $defaultTop = 0;
  71. var $defaultRight = 0;
  72. var $defaultBottom = 0;
  73. var $margeLeft = 0; //marges r�elles de la page
  74. var $margeTop = 0;
  75. var $margeRight = 0;
  76. var $margeBottom = 0;
  77. var $marges = array();
  78. var $Maxs = array();
  79. var $maxH = 0; // plus grande hauteur dans la ligne, pour saut de ligne � corriger
  80. var $inLink = ''; // indique si on est � l'interieur d'un lien
  81. var $lstAncre = array(); // liste des ancres d�tect�es ou cr��es
  82. var $subHEADER = array(); // tableau des sous commandes pour faire l'HEADER
  83. var $subFOOTER = array(); // tableau des sous commandes pour faire le FOOTER
  84. var $subSTATES = array(); // tableau de sauvegarde de certains param�tres
  85. var $defLIST = array(); // tableau de sauvegarde de l'etat des UL et OL
  86. var $lstChamps = array(); // liste des champs
  87. var $lstSelect = array(); // options du select en cours
  88. var $previousCall = null; // dernier appel
  89. var $isInTfoot = false; // indique si on est dans un tfoot
  90. var $pageMarges = array(); // marges sp�cifiques dues aux floats
  91. var $isAfterFloat = false; // indique si on est apres un float
  92. var $forOneLine = false; // indique si on est dans un sous HTML ne servant qu'a calculer la taille de la prochaine ligne
  93. /**
  94. * Constructeur
  95. *
  96. * @param string sens portrait ou landscape
  97. * @param string format A4, A5, ...
  98. * @param string langue : fr, en, it...
  99. * @param array marges par defaut, dans l'ordre (left, top, right, bottom)
  100. * @param boolean forcer la cr�ation de la premiere page, ne pas utiliser, c'est utilis� en interne pour la gestion des tableaux
  101. * @return null
  102. */
  103. function HTML2PDF($sens = 'P', $format = 'A4', $langue='fr', $marges = array(5, 5, 5, 8), $force_page = false)
  104. {
  105. // sauvegarde des param�tres
  106. $this->sens = $sens;
  107. $this->format = $format;
  108. $this->FirstPage = true;
  109. $this->langue = strtolower($langue);
  110. $this->setTestTdInOnePage(true);
  111. // chargement du fichier de langue
  112. $this->textLOAD($this->langue);
  113. // cr�ation de l' objet PDF
  114. $this->pdf = new MyPDF($sens, 'mm', $format);
  115. // initialisation des styles
  116. $this->style = new styleHTML($this->pdf);
  117. $this->style->FontSet();
  118. $this->defLIST = array();
  119. // initialisation du parsing
  120. $this->parsing = new parsingHTML();
  121. $this->sub_html = null;
  122. $this->sub_part = false;
  123. // initialisation des marges
  124. $this->setDefaultMargins($marges[0], $marges[1], $marges[2], $marges[3]);
  125. $this->setMargins();
  126. $this->marges = array();
  127. // initialisation des champs de formulaire
  128. $this->lstChamps = array();
  129. // premier page forc�e
  130. if ($force_page) $this->setNewPage($this->sens);
  131. }
  132. /**
  133. * activer ou desactiver le test de TD ne devant pas depasser une page
  134. *
  135. * @param boolean nouvel etat
  136. * @return boolean ancien etat
  137. */
  138. function setTestTdInOnePage($mode = true)
  139. {
  140. $old = $this->testTDin1page;
  141. $this->testTDin1page = $mode ? true : false;
  142. return $old;
  143. }
  144. /**
  145. * d�finir les marges par d�fault
  146. *
  147. * @param int en mm, marge left
  148. * @param int en mm, marge top
  149. * @param int en mm, marge right. si null, left=right
  150. * @param int en mm, marge bottom. si null, bottom=8
  151. * @return null
  152. */
  153. function setDefaultMargins($left, $top, $right = null, $bottom = null)
  154. {
  155. if ($right===null) $right = $left;
  156. if ($bottom===null) $bottom = 8;
  157. $this->defaultLeft = $this->style->ConvertToMM($left.'mm');
  158. $this->defaultTop = $this->style->ConvertToMM($top.'mm');
  159. $this->defaultRight = $this->style->ConvertToMM($right.'mm');
  160. $this->defaultBottom = $this->style->ConvertToMM($bottom.'mm');
  161. }
  162. /**
  163. * d�finir les marges r�elles, fonctions de la balise page
  164. *
  165. * @return null
  166. */
  167. function setMargins()
  168. {
  169. $this->margeLeft = $this->defaultLeft + (isset($this->background['left']) ? $this->background['left'] : 0);
  170. $this->margeRight = $this->defaultRight + (isset($this->background['right']) ? $this->background['right'] : 0);
  171. $this->margeTop = $this->defaultTop + (isset($this->background['top']) ? $this->background['top'] : 0);
  172. $this->margeBottom = $this->defaultBottom + (isset($this->background['bottom']) ? $this->background['bottom'] : 0);
  173. $this->pdf->SetMargins($this->margeLeft, $this->margeTop, $this->margeRight);
  174. $this->pdf->cMargin = 0;
  175. $this->pdf->SetAutoPageBreak(false, $this->margeBottom);
  176. }
  177. /**
  178. * recuperer les positions x minimales et maximales en fonction d'une hauteur
  179. *
  180. * @param float y
  181. * @return array(float, float)
  182. */
  183. function getMargins($y)
  184. {
  185. $y = floor($y*100);
  186. $x = array($this->pdf->lMargin, $this->pdf->w-$this->pdf->rMargin);
  187. foreach($this->pageMarges as $m_y => $m_x)
  188. if ($m_y<=$y) $x = $m_x;
  189. return $x;
  190. }
  191. /**
  192. * ajouter une marge suite a un float
  193. *
  194. * @param string left ou right
  195. * @param float x1
  196. * @param float y1
  197. * @param float x2
  198. * @param float y2
  199. * @return null
  200. */
  201. function addMargins($float, $x1, $y1, $x2, $y2)
  202. {
  203. $old1 = $this->getMargins($y1);
  204. $old2 = $this->getMargins($y2);
  205. if ($float=='left') $old1[0] = $x2;
  206. if ($float=='right') $old1[1] = $x1;
  207. $y1 = floor($y1*100);
  208. $y2 = floor($y2*100);
  209. foreach($this->pageMarges as $m_y => $m_x)
  210. {
  211. if ($m_y<$y1) continue;
  212. if ($m_y>$y2) break;
  213. if ($float=='left' && $this->pageMarges[$m_y][0]<$x2) unset($this->pageMarges[$m_y]);
  214. if ($float=='right' && $this->pageMarges[$m_y][1]>$x1) unset($this->pageMarges[$m_y]);
  215. }
  216. $this->pageMarges[$y1] = $old1;
  217. $this->pageMarges[$y2] = $old2;
  218. ksort($this->pageMarges);
  219. $this->isAfterFloat = true;
  220. }
  221. /**
  222. * d�finir des nouvelles marges et sauvegarder les anciennes
  223. *
  224. * @param float marge left
  225. * @param float marge top
  226. * @param float marge right
  227. * @return null
  228. */
  229. function saveMargin($ml, $mt, $mr)
  230. {
  231. $this->marges[] = array('l' => $this->pdf->lMargin, 't' => $this->pdf->tMargin, 'r' => $this->pdf->rMargin, 'page' => $this->pageMarges);
  232. $this->pdf->SetMargins($ml, $mt, $mr);
  233. $this->pageMarges = array();
  234. $this->pageMarges[floor($mt*100)] = array($ml, $this->pdf->w-$mr);
  235. }
  236. /**
  237. * r�cuperer les derni�res marches sauv�es
  238. *
  239. * @return null
  240. */
  241. function loadMargin()
  242. {
  243. $old = array_pop($this->marges);
  244. if ($old)
  245. {
  246. $ml = $old['l'];
  247. $mt = $old['t'];
  248. $mr = $old['r'];
  249. $mP = $old['page'];
  250. }
  251. else
  252. {
  253. $ml = $this->margeLeft;
  254. $mt = 0;
  255. $mr = $this->margeRight;
  256. $mP = array($mt => array($ml, $this->pdf->w-$mr));
  257. }
  258. $this->pdf->SetMargins($ml, $mt, $mr);
  259. $this->pageMarges = $mP;
  260. }
  261. /**
  262. * permet d'ajouter une fonte.
  263. *
  264. * @param string nom de la fonte
  265. * @param string style de la fonte
  266. * @param string fichier de la fonte
  267. * @return null
  268. */
  269. function AddFont($family, $style='', $file='')
  270. {
  271. $this->pdf->AddFont($family, $style, $file);
  272. }
  273. /**
  274. * sauvegarder l'�tat actuelle des maximums
  275. *
  276. * @return null
  277. */
  278. function saveMax()
  279. {
  280. $this->Maxs[] = array($this->maxX, $this->maxY, $this->maxH);
  281. }
  282. /**
  283. * charger le dernier �tat sauv� des maximums
  284. *
  285. * @return null
  286. */
  287. function loadMax()
  288. {
  289. $old = array_pop($this->Maxs);
  290. if ($old)
  291. {
  292. $this->maxX = $old[0];
  293. $this->maxY = $old[1];
  294. $this->maxH = $old[2];
  295. }
  296. else
  297. {
  298. $this->maxX = 0;
  299. $this->maxY = 0;
  300. $this->maxH = 0;
  301. }
  302. }
  303. /**
  304. * afficher l'header contenu dans page_header
  305. *
  306. * @return null
  307. */
  308. function SetPageHeader()
  309. {
  310. if (!count($this->subHEADER)) return false;
  311. $OLD_parse_pos = $this->parse_pos;
  312. $OLD_parse_code = $this->parsing->code;
  313. $this->parse_pos = 0;
  314. $this->parsing->code = $this->subHEADER;
  315. $this->MakeHTMLcode();
  316. $this->parse_pos = $OLD_parse_pos;
  317. $this->parsing->code = $OLD_parse_code;
  318. }
  319. /**
  320. * afficher le footer contenu dans page_footer
  321. *
  322. * @return null
  323. */
  324. function SetPageFooter()
  325. {
  326. if (!count($this->subFOOTER)) return false;
  327. $OLD_parse_pos = $this->parse_pos;
  328. $OLD_parse_code = $this->parsing->code;
  329. $this->parse_pos = 0;
  330. $this->parsing->code = $this->subFOOTER;
  331. $this->MakeHTMLcode();
  332. $this->parse_pos = $OLD_parse_pos;
  333. $this->parsing->code = $OLD_parse_code;
  334. }
  335. /**
  336. * saut de ligne avec une hauteur sp�cifique
  337. *
  338. * @param float hauteur de la ligne
  339. * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
  340. * @return null
  341. */
  342. function setNewLine($h, $curr = null)
  343. {
  344. $this->pdf->Ln($h);
  345. $this->setNewPositionForNewLine($curr);
  346. }
  347. /**
  348. * cr�ation d'une nouvelle page avec une orientation particuliere
  349. *
  350. * @param string sens P=portrait ou L=landscape
  351. * @param array tableau des propri�t�s du fond de la page
  352. * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
  353. * @return null
  354. */
  355. function setNewPage($orientation = '', $background = null, $curr = null)
  356. {
  357. /*
  358. if (!$this->FirstPage)
  359. {
  360. $info = debug_backtrace(); foreach($info as $k => $v) { unset($info[$k]['object']); unset($info[$k]['type']); unset($info[$k]['args']);}
  361. echo '<pre>'.print_r($info, true).'</pre><hr>';
  362. }
  363. */
  364. $this->FirstPage = false;
  365. $this->sens = $orientation ? $orientation : $this->sens;
  366. $this->background = $background!==null ? $background : $this->background;
  367. $this->maxY = 0;
  368. $this->maxX = 0;
  369. $this->pdf->lMargin = $this->defaultLeft;
  370. $this->pdf->rMargin = $this->defaultRight;
  371. $this->pdf->tMargin = $this->defaultTop;
  372. $this->pdf->AddPage($this->sens);
  373. if (!$this->sub_part && !$this->isSubPart)
  374. {
  375. if (is_array($this->background))
  376. {
  377. if (isset($this->background['color']) && $this->background['color'])
  378. {
  379. $this->pdf->SetFillColor($this->background['color'][0], $this->background['color'][1], $this->background['color'][2]);
  380. $this->pdf->Rect(0, 0, $this->pdf->w, $this->pdf->h, 'F');
  381. }
  382. if (isset($this->background['img']) && $this->background['img'])
  383. $this->pdf->Image($this->background['img'], $this->background['posX'], $this->background['posY'], $this->background['width']);
  384. }
  385. $this->SetPageHeader();
  386. $this->SetPageFooter();
  387. }
  388. $this->SetMargins();
  389. $this->pdf->y = $this->margeTop;
  390. $this->setNewPositionForNewLine($curr);
  391. }
  392. /**
  393. * calcul de la position de debut de la prochaine ligne en fonction de l'alignement voulu
  394. *
  395. * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
  396. * @return null
  397. */
  398. function setNewPositionForNewLine($curr = null)
  399. {
  400. list($lx, $rx) = $this->getMargins($this->pdf->y);
  401. $this->pdf->x=$lx;
  402. if (
  403. $this->style->value['text-align']!='right' &&
  404. $this->style->value['text-align']!='center'
  405. )
  406. return null;
  407. $sub = null;
  408. $this->CreateSubHTML($sub);
  409. $sub->saveMargin(0, 0, $sub->pdf->w-$rx+$lx);
  410. $sub->forOneLine = true;
  411. $sub->parse_pos = $this->parse_pos;
  412. $sub->parsing->code = $this->parsing->code;
  413. if ($curr!==null && $sub->parsing->code[$this->parse_pos]['name']=='write')
  414. $sub->parsing->code[$this->parse_pos]['param']['txt'] = substr($sub->parsing->code[$this->parse_pos]['param']['txt'], $curr);
  415. else
  416. $sub->parse_pos++;
  417. // pour chaque element identifi� par le parsing
  418. for($sub->parse_pos; $sub->parse_pos<count($sub->parsing->code); $sub->parse_pos++)
  419. {
  420. $todo = $sub->parsing->code[$sub->parse_pos];
  421. if (!$sub->loadAction($todo)) break;
  422. }
  423. $w = $sub->maxX;
  424. unset($sub);
  425. if ($this->style->value['text-align']=='center')
  426. $this->pdf->x+= ($rx-$this->pdf->x-$w)*0.5-0.01;
  427. else
  428. $this->pdf->x = $rx-$w-0.01;
  429. }
  430. /**
  431. * r�cup�ration du PDF
  432. *
  433. * @param string nom du fichier PDF
  434. * @param boolean destination
  435. * @return string contenu �ventuel du pdf
  436. *
  437. *
  438. * Destination o� envoyer le document. Le param�tre peut prendre les valeurs suivantes :
  439. * true : equivalent � I
  440. * false : equivalent � S
  441. * I : envoyer en inline au navigateur. Le plug-in est utilis� s'il est install�. Le nom indiqu� dans name est utilis� lorsque l'on s�lectionne "Enregistrer sous" sur le lien g�n�rant le PDF.
  442. * D : envoyer au navigateur en for�ant le t�l�chargement, avec le nom indiqu� dans name.
  443. * F : sauver dans un fichier local, avec le nom indiqu� dans name (peut inclure un r�pertoire).
  444. * S : renvoyer le document sous forme de cha�ne. name est ignor�.
  445. */
  446. function Output($name = '', $dest = false)
  447. {
  448. // nettoyage
  449. global $HTML2PDF_TABLEAU; $HTML2PDF_TABLEAU = array();
  450. // interpretation des param�tres
  451. if ($dest===false) $dest = 'I';
  452. if ($dest===true) $dest = 'S';
  453. if ($dest==='') $dest = 'I';
  454. if ($name=='') $name='document.pdf';
  455. // verification de la destination
  456. $dest = strtoupper($dest);
  457. if (!in_array($dest, array('I', 'D', 'F', 'S'))) $dest = 'I';
  458. // verification du nom
  459. if (strtolower(substr($name, -4))!='.pdf')
  460. {
  461. echo 'ERROR : The output document name "'.$name.'" is not a PDF name';
  462. exit;
  463. }
  464. return $this->pdf->Output($name, $dest);
  465. }
  466. /**
  467. * cr�ation d'un sous HTML2PDF pour la gestion des tableaux imbriqu�s
  468. *
  469. * @param HTML2PDF futur sous HTML2PDF pass� en r�f�rence pour cr�ation
  470. * @param integer marge eventuelle de l'objet si simulation d'un TD
  471. * @return null
  472. */
  473. function CreateSubHTML(&$sub_html, $cellmargin=0)
  474. {
  475. // initialisation du sous objet
  476. $sub_html = new HTML2PDF(
  477. $this->sens,
  478. $this->format,
  479. $this->langue,
  480. array($this->defaultLeft,$this->defaultTop,$this->defaultRight,$this->defaultBottom),
  481. true
  482. );
  483. $sub_html->isSubPart = true;
  484. $sub_html->setTestTdInOnePage($this->testTDin1page);
  485. $sub_html->style->css = $this->style->css;
  486. $sub_html->style->css_keys = $this->style->css_keys;
  487. $sub_html->style->table = $this->style->table;
  488. $sub_html->style->value = $this->style->value;
  489. $sub_html->style->value['text-align'] = 'left';
  490. $sub_html->defLIST = $this->defLIST;
  491. $sub_html->style->onlyLeft = true;
  492. // initialisation de la largeur
  493. if ($this->style->value['width'])
  494. {
  495. $marge = $cellmargin*2;
  496. $marge+= $this->style->value['padding']['l'] + $this->style->value['padding']['r'];
  497. $marge+= $this->style->value['border']['l']['width'] + $this->style->value['border']['r']['width'];
  498. $marge = $sub_html->pdf->w - $this->style->value['width'] + $marge;
  499. }
  500. else
  501. $marge = $this->margeLeft+$this->margeRight;
  502. $sub_html->saveMargin(0, 0, $marge);
  503. // initialisation des fontes
  504. $sub_html->pdf->fonts = &$this->pdf->fonts;
  505. $sub_html->pdf->FontFiles = &$this->pdf->FontFiles;
  506. $sub_html->pdf->diffs = &$this->pdf->diffs;
  507. // initialisation des positions et autre
  508. $sub_html->maxX = 0;
  509. $sub_html->maxY = 0;
  510. $sub_html->maxH = 0;
  511. $sub_html->pdf->setX(0);
  512. $sub_html->pdf->setY(0);
  513. $sub_html->style->FontSet();
  514. }
  515. /**
  516. * destruction d'un sous HTML2PDF pour la gestion des tableaux imbriqu�s
  517. *
  518. * @return null
  519. */
  520. function DestroySubHTML()
  521. {
  522. unset($this->sub_html);
  523. $this->sub_html = null;
  524. }
  525. /**
  526. * Convertir un nombre arabe en nombre romain
  527. *
  528. * @param integer nombre � convertir
  529. * @return string nombre converti
  530. */
  531. function listeArab2Rom($nb_ar)
  532. {
  533. $nb_b10 = array('I','X','C','M');
  534. $nb_b5 = array('V','L','D');
  535. $nb_ro = '';
  536. if ($nb_ar<1) return $nb_ar;
  537. if ($nb_ar>3999) return $nb_ar;
  538. for($i=3; $i>=0 ; $i--)
  539. {
  540. $chiffre=floor($nb_ar/pow(10,$i));
  541. if($chiffre>=1)
  542. {
  543. $nb_ar=$nb_ar-$chiffre*pow(10,$i);
  544. if($chiffre<=3)
  545. {
  546. for($j=$chiffre; $j>=1; $j--)
  547. {
  548. $nb_ro=$nb_ro.$nb_b10[$i];
  549. }
  550. }
  551. else if($chiffre==9)
  552. {
  553. $nb_ro=$nb_ro.$nb_b10[$i].$nb_b10[$i+1];
  554. }
  555. elseif($chiffre==4)
  556. {
  557. $nb_ro=$nb_ro.$nb_b10[$i].$nb_b5[$i];
  558. }
  559. else
  560. {
  561. $nb_ro=$nb_ro.$nb_b5[$i];
  562. for($j=$chiffre-5; $j>=1; $j--)
  563. {
  564. $nb_ro=$nb_ro.$nb_b10[$i];
  565. }
  566. }
  567. }
  568. }
  569. return $nb_ro;
  570. }
  571. /**
  572. * Ajouter un LI au niveau actuel
  573. *
  574. * @return null
  575. */
  576. function listeAddLi()
  577. {
  578. $this->defLIST[count($this->defLIST)-1]['nb']++;
  579. }
  580. function listeGetWidth() { return '7mm'; }
  581. function listeGetPadding() { return '1mm'; }
  582. /**
  583. * Recuperer le LI du niveau actuel
  584. *
  585. * @return string chaine � afficher
  586. */
  587. function listeGetLi()
  588. {
  589. $im = $this->defLIST[count($this->defLIST)-1]['img'];
  590. $st = $this->defLIST[count($this->defLIST)-1]['style'];
  591. $nb = $this->defLIST[count($this->defLIST)-1]['nb'];
  592. $up = (substr($st, 0, 6)=='upper-');
  593. if ($im) return array(false, false, $im);
  594. switch($st)
  595. {
  596. case 'none':
  597. return array('arial', true, ' ');
  598. case 'upper-alpha':
  599. case 'lower-alpha':
  600. $str = '';
  601. while($nb>26)
  602. {
  603. $str = chr(96+$nb%26).$str;
  604. $nb = floor($nb/26);
  605. }
  606. $str = chr(96+$nb).$str;
  607. return array('arial', false, ($up ? strtoupper($str) : $str).'.');
  608. case 'upper-roman':
  609. case 'lower-roman':
  610. $str = $this->listeArab2Rom($nb);
  611. return array('arial', false, ($up ? strtoupper($str) : $str).'.');
  612. case 'decimal':
  613. return array('arial', false, $nb.'.');
  614. case 'square':
  615. return array('zapfdingbats', true, chr(110));
  616. case 'circle':
  617. return array('zapfdingbats', true, chr(109));
  618. case 'disc':
  619. default:
  620. return array('zapfdingbats', true, chr(108));
  621. }
  622. }
  623. /**
  624. * Ajouter un niveau de liste
  625. *
  626. * @param string type de liste : ul, ol
  627. * @param string style de la liste
  628. * @return null
  629. */
  630. function listeAddLevel($type = 'ul', $style = '', $img = null)
  631. {
  632. if ($img)
  633. {
  634. if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match))
  635. $img = $match[1];
  636. else
  637. $img = null;
  638. }
  639. else
  640. $img = null;
  641. if (!in_array($type, array('ul', 'ol'))) $type = 'ul';
  642. if (!in_array($style, array('lower-alpha', 'upper-alpha', 'upper-roman', 'lower-roman', 'decimal', 'square', 'circle', 'disc', 'none'))) $style = '';
  643. if (!$style)
  644. {
  645. if ($type=='ul') $style = 'disc';
  646. else $style = 'decimal';
  647. }
  648. $this->defLIST[count($this->defLIST)] = array('style' => $style, 'nb' => 0, 'img' => $img);
  649. }
  650. /**
  651. * Supprimer un niveau de liste
  652. *
  653. * @return null
  654. */
  655. function listeDelLevel()
  656. {
  657. if (count($this->defLIST))
  658. {
  659. unset($this->defLIST[count($this->defLIST)-1]);
  660. $this->defLIST = array_values($this->defLIST);
  661. }
  662. }
  663. /**
  664. * traitement d'un code HTML
  665. *
  666. * @param string code HTML � convertir
  667. * @param boolean afficher en pdf (false) ou en html (true)
  668. * @return null
  669. */
  670. function WriteHTML($html, $vue = false)
  671. {
  672. $html = str_replace('[[page_nb]]', '{nb}', $html);
  673. $html = str_replace('[[date_y]]', date('Y'), $html);
  674. $html = str_replace('[[date_m]]', date('m'), $html);
  675. $html = str_replace('[[date_d]]', date('d'), $html);
  676. $html = str_replace('[[date_h]]', date('H'), $html);
  677. $html = str_replace('[[date_i]]', date('i'), $html);
  678. $html = str_replace('[[date_s]]', date('s'), $html);
  679. // si on veut voir le r�sultat en HTML => on appelle la fonction
  680. if ($vue) $this->vueHTML($html);
  681. // sinon, traitement pour conversion en PDF :
  682. // parsing
  683. $this->sub_pdf = false;
  684. $this->style->readStyle($html);
  685. $this->parsing->setHTML($html);
  686. $this->parsing->parse();
  687. $this->MakeHTMLcode();
  688. }
  689. function MakeHTMLcode()
  690. {
  691. // pour chaque element identifi� par le parsing
  692. for($this->parse_pos=0; $this->parse_pos<count($this->parsing->code); $this->parse_pos++)
  693. {
  694. // r�cup�ration de l'�l�ment
  695. $todo = $this->parsing->code[$this->parse_pos];
  696. // si c'est une ouverture de tableau
  697. if (in_array($todo['name'], array('table', 'ul', 'ol')) && !$todo['close'])
  698. {
  699. // on va cr�er un sous HTML, et on va travailler sur une position temporaire
  700. $tag_open = $todo['name'];
  701. $this->sub_part = true;
  702. $this->temp_pos = $this->parse_pos;
  703. // pour tous les �l�ments jusqu'� la fermeture de la table afin de pr�parer les dimensions
  704. while(isset($this->parsing->code[$this->temp_pos]) && !($this->parsing->code[$this->temp_pos]['name']==$tag_open && $this->parsing->code[$this->temp_pos]['close']))
  705. {
  706. $this->loadAction($this->parsing->code[$this->temp_pos]);
  707. $this->temp_pos++;
  708. }
  709. if (isset($this->parsing->code[$this->temp_pos])) $this->loadAction($this->parsing->code[$this->temp_pos]);
  710. $this->sub_part = false;
  711. }
  712. // chargement de l'action correspondant � l'�l�ment
  713. $this->loadAction($todo);
  714. }
  715. }
  716. /**
  717. * affichage en mode HTML du contenu
  718. *
  719. * @param string contenu
  720. * @return null
  721. */
  722. function vueHTML($content)
  723. {
  724. $content = preg_replace('/<page_header([^>]*)>/isU', '<hr>'.@HTML2PDF::textGET('vue01').' : $1<hr><div$1>', $content);
  725. $content = preg_replace('/<page_footer([^>]*)>/isU', '<hr>'.@HTML2PDF::textGET('vue02').' : $1<hr><div$1>', $content);
  726. $content = preg_replace('/<page([^>]*)>/isU', '<hr>'.@HTML2PDF::textGET('vue03').' : $1<hr><div$1>', $content);
  727. $content = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $content);
  728. $content = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $content);
  729. $content = preg_replace('/<\/bookmark([^>]*)>/isU', '', $content);
  730. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  731. <html>
  732. <head>
  733. <title>'.@HTML2PDF::textGET('vue04').' HTML</title>
  734. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
  735. </head>
  736. <body style="padding: 10px; font-size: 10pt;font-family: Arial;">
  737. '.$content.'
  738. </body>
  739. </html>';
  740. exit;
  741. }
  742. /**
  743. * chargement de l'action correspondante � un element de parsing
  744. *
  745. * @param array �l�ment de parsing
  746. * @return null
  747. */
  748. function loadAction($row)
  749. {
  750. // nom de l'action
  751. $fnc = ($row['close'] ? 'c_' : 'o_').strtoupper($row['name']);
  752. // parametres de l'action
  753. $param = $row['param'];
  754. // si aucune page n'est cr��, on la cr��
  755. if ($fnc!='o_PAGE' && $this->FirstPage)
  756. {
  757. $this->setNewPage();
  758. }
  759. // lancement de l'action
  760. if (is_callable(array(&$this, $fnc)))
  761. {
  762. $res = $this->{$fnc}($param);
  763. $this->previousCall = $fnc;
  764. return $res;
  765. }
  766. else
  767. {
  768. @HTML2PDF::makeError(1, __FILE__, __LINE__, strtoupper($row['name']));
  769. return false;
  770. }
  771. }
  772. /**
  773. * balise : PAGE
  774. * mode : OUVERTURE
  775. *
  776. * @param array param�tres de l'�l�ment de parsing
  777. * @return null
  778. */
  779. function o_PAGE($param)
  780. {
  781. if ($this->forOneLine) return false;
  782. $newPageSet= (!isset($param['pageset']) || $param['pageset']!='old');
  783. $this->maxH = 0;
  784. if ($newPageSet)
  785. {
  786. $this->subHEADER = array();
  787. $this->subFOOTER = array();
  788. // identification de l'orientation demand�e
  789. $orientation = '';
  790. if (isset($param['orientation']))
  791. {
  792. $param['orientation'] = strtolower($param['orientation']);
  793. if ($param['orientation']=='p') $orientation = 'P';
  794. if ($param['orientation']=='portrait') $orientation = 'P';
  795. if ($param['orientation']=='l') $orientation = 'L';
  796. if ($param['orientation']=='paysage') $orientation = 'L';
  797. if ($param['orientation']=='landscape') $orientation = 'L';
  798. }
  799. // identification des propri�t�s du background
  800. $background = array();
  801. if (isset($param['backimg']))
  802. {
  803. $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // nom de l'image
  804. $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // position horizontale de l'image
  805. $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // position verticale de l'image
  806. $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // taille de l'image (100% = largueur de la feuille)
  807. // conversion du nom de l'image, en cas de param�tres en _GET
  808. $background['img'] = str_replace('&amp;', '&', $background['img']);
  809. // conversion des positions
  810. if ($background['posX']=='left') $background['posX'] = '0%';
  811. if ($background['posX']=='center') $background['posX'] = '50%';
  812. if ($background['posX']=='right') $background['posX'] = '100%';
  813. if ($background['posY']=='top') $background['posY'] = '0%';
  814. if ($background['posY']=='middle') $background['posY'] = '50%';
  815. if ($background['posY']=='bottom') $background['posY'] = '100%';
  816. // si il y a une image de pr�cis�
  817. if ($background['img'])
  818. {
  819. // est-ce que c'est une image ?
  820. $infos=@GetImageSize($background['img']);
  821. if (count($infos)>1)
  822. {
  823. // taille de l'image, en fonction de la taille sp�cifi�e.
  824. $Wi = $this->style->ConvertToMM($background['width'], $this->pdf->w);
  825. $Hi = $Wi*$infos[1]/$infos[0];
  826. // r�cup�ration des dimensions et positions de l'image
  827. $background['width'] = $Wi;
  828. $background['posX'] = $this->style->ConvertToMM($background['posX'], $this->pdf->w - $Wi);
  829. $background['posY'] = $this->style->ConvertToMM($background['posY'], $this->pdf->h - $Hi);
  830. }
  831. else
  832. $background = array();
  833. }
  834. else
  835. $background = array();
  836. }
  837. // marges TOP et BOTTOM pour le texte.
  838. $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0';
  839. $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0';
  840. $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0';
  841. $background['right'] = isset($param['backright']) ? $param['backright'] : '0';
  842. if (preg_match('/^([0-9]*)$/isU', $background['top'])) $background['top'] .= 'mm';
  843. if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) $background['bottom'] .= 'mm';
  844. if (preg_match('/^([0-9]*)$/isU', $background['left'])) $background['left'] .= 'mm';
  845. if (preg_match('/^([0-9]*)$/isU', $background['right'])) $background['right'] .= 'mm';
  846. $background['top'] = $this->style->ConvertToMM($background['top'], $this->pdf->h);
  847. $background['bottom'] = $this->style->ConvertToMM($background['bottom'], $this->pdf->h);
  848. $background['left'] = $this->style->ConvertToMM($background['left'], $this->pdf->w);
  849. $background['right'] = $this->style->ConvertToMM($background['right'], $this->pdf->w);
  850. $res = false;
  851. $background['color'] = isset($param['backcolor']) ? $this->style->ConvertToRVB($param['backcolor'], $res) : null;
  852. if (!$res) $background['color'] = null;
  853. $this->style->save();
  854. $this->style->analyse('PAGE', $param);
  855. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  856. $this->style->FontSet();
  857. // nouvelle page
  858. $this->setNewPage($orientation, $background);
  859. // footer automatique
  860. if (isset($param['footer']))
  861. {
  862. $lst = explode(';', $param['footer']);
  863. foreach($lst as $key => $val) $lst[$key] = trim(strtolower($val));
  864. $page = in_array('page', $lst);
  865. $date = in_array('date', $lst);
  866. $heure = in_array('heure', $lst);
  867. $form = in_array('form', $lst);
  868. }
  869. else
  870. {
  871. $page = null;
  872. $date = null;
  873. $heure = null;
  874. $form = null;
  875. }
  876. $this->pdf->SetMyFooter($page, $date, $heure, $form);
  877. }
  878. else
  879. {
  880. $this->style->save();
  881. $this->style->analyse('PAGE', $param);
  882. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  883. $this->style->FontSet();
  884. $this->setNewPage();
  885. }
  886. return true;
  887. }
  888. /**
  889. * balise : PAGE
  890. * mode : FERMETURE
  891. *
  892. * @param array param�tres de l'�l�ment de parsing
  893. * @return null
  894. */
  895. function c_PAGE($param)
  896. {
  897. if ($this->forOneLine) return false;
  898. $this->maxH = 0;
  899. $this->style->load();
  900. $this->style->FontSet();
  901. return true;
  902. }
  903. function o_PAGE_HEADER($param)
  904. {
  905. if ($this->forOneLine) return false;
  906. $this->subHEADER = array();
  907. for($this->parse_pos; $this->parse_pos<count($this->parsing->code); $this->parse_pos++)
  908. {
  909. $todo = $this->parsing->code[$this->parse_pos];
  910. if ($todo['name']=='page_header') $todo['name']='page_header_sub';
  911. $this->subHEADER[] = $todo;
  912. if (strtolower($todo['name'])=='page_header_sub' && $todo['close']) break;
  913. }
  914. $this->SetPageHeader();
  915. return true;
  916. }
  917. function o_PAGE_FOOTER($param)
  918. {
  919. if ($this->forOneLine) return false;
  920. $this->subFOOTER = array();
  921. for($this->parse_pos; $this->parse_pos<count($this->parsing->code); $this->parse_pos++)
  922. {
  923. $todo = $this->parsing->code[$this->parse_pos];
  924. if ($todo['name']=='page_footer') $todo['name']='page_footer_sub';
  925. $this->subFOOTER[] = $todo;
  926. if (strtolower($todo['name'])=='page_footer_sub' && $todo['close']) break;
  927. }
  928. $this->SetPageFooter();
  929. return true;
  930. }
  931. function o_PAGE_HEADER_SUB($param)
  932. {
  933. if ($this->forOneLine) return false;
  934. $this->subSTATES = array();
  935. $this->subSTATES['x'] = $this->pdf->x;
  936. $this->subSTATES['y'] = $this->pdf->y;
  937. $this->subSTATES['s'] = $this->style->value;
  938. $this->subSTATES['t'] = $this->style->table;
  939. $this->subSTATES['ml'] = $this->pdf->lMargin;
  940. $this->subSTATES['mr'] = $this->pdf->rMargin;
  941. $this->subSTATES['mt'] = $this->pdf->tMargin;
  942. $this->subSTATES['mb'] = $this->pdf->bMargin;
  943. $this->pdf->x = $this->defaultLeft;
  944. $this->pdf->y = $this->defaultTop;
  945. $this->style->initStyle();
  946. $this->style->resetStyle();
  947. $this->style->value['width'] = $this->pdf->w - $this->defaultLeft - $this->defaultRight;
  948. $this->style->table = array();
  949. $this->pdf->lMargin = $this->defaultLeft;
  950. $this->pdf->rMargin = $this->defaultRight;
  951. $this->pdf->tMargin = $this->defaultTop;
  952. $this->pdf->bMargin = $this->defaultBottom;
  953. $this->pdf->PageBreakTrigger = $this->pdf->h - $this->pdf->bMargin;
  954. $this->style->save();
  955. $this->style->analyse('page_header_sub', $param);
  956. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  957. $this->style->FontSet();
  958. return true;
  959. }
  960. function c_PAGE_HEADER_SUB($param)
  961. {
  962. if ($this->forOneLine) return false;
  963. $this->style->load();
  964. $this->pdf->x = $this->subSTATES['x'];
  965. $this->pdf->y = $this->subSTATES['y'];
  966. $this->style->value = $this->subSTATES['s'];
  967. $this->style->table = $this->subSTATES['t'];
  968. $this->pdf->lMargin = $this->subSTATES['ml'];
  969. $this->pdf->rMargin = $this->subSTATES['mr'];
  970. $this->pdf->tMargin = $this->subSTATES['mt'];
  971. $this->pdf->bMargin = $this->subSTATES['mb'];
  972. $this->pdf->PageBreakTrigger = $this->pdf->h - $this->pdf->bMargin;
  973. $this->style->FontSet();
  974. return true;
  975. }
  976. function o_PAGE_FOOTER_SUB($param)
  977. {
  978. if ($this->forOneLine) return false;
  979. $this->subSTATES = array();
  980. $this->subSTATES['x'] = $this->pdf->x;
  981. $this->subSTATES['y'] = $this->pdf->y;
  982. $this->subSTATES['s'] = $this->style->value;
  983. $this->subSTATES['t'] = $this->style->table;
  984. $this->subSTATES['ml'] = $this->pdf->lMargin;
  985. $this->subSTATES['mr'] = $this->pdf->rMargin;
  986. $this->subSTATES['mt'] = $this->pdf->tMargin;
  987. $this->subSTATES['mb'] = $this->pdf->bMargin;
  988. $this->pdf->x = $this->defaultLeft;
  989. $this->pdf->y = $this->defaultTop;
  990. $this->style->initStyle();
  991. $this->style->resetStyle();
  992. $this->style->value['width'] = $this->pdf->w - $this->defaultLeft - $this->defaultRight;
  993. $this->style->table = array();
  994. $this->pdf->lMargin = $this->defaultLeft;
  995. $this->pdf->rMargin = $this->defaultRight;
  996. $this->pdf->tMargin = $this->defaultTop;
  997. $this->pdf->bMargin = $this->defaultBottom;
  998. $this->pdf->PageBreakTrigger = $this->pdf->h - $this->pdf->bMargin;
  999. // on en cr�� un sous HTML que l'on transforme en PDF
  1000. // pour r�cup�rer la hauteur
  1001. // on extrait tout ce qui est contenu dans le FOOTER
  1002. $sub = null;
  1003. $res = $this->parsing->getLevel($this->parse_pos);
  1004. $this->CreateSubHTML($sub);
  1005. $sub->writeHTML($res[1]);
  1006. $this->pdf->y = $this->pdf->h - $sub->maxY - $this->defaultBottom - 0.01;
  1007. unset($sub);
  1008. $this->style->save();
  1009. $this->style->analyse('page_footer_sub', $param);
  1010. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1011. $this->style->FontSet();
  1012. return true;
  1013. }
  1014. function c_PAGE_FOOTER_SUB($param)
  1015. {
  1016. if ($this->forOneLine) return false;
  1017. $this->style->load();
  1018. $this->pdf->x = $this->subSTATES['x'];
  1019. $this->pdf->y = $this->subSTATES['y'];
  1020. $this->style->value = $this->subSTATES['s'];
  1021. $this->style->table = $this->subSTATES['t'];
  1022. $this->pdf->lMargin = $this->subSTATES['ml'];
  1023. $this->pdf->rMargin = $this->subSTATES['mr'];
  1024. $this->pdf->tMargin = $this->subSTATES['mt'];
  1025. $this->pdf->bMargin = $this->subSTATES['mb'];
  1026. $this->pdf->PageBreakTrigger = $this->pdf->h - $this->pdf->bMargin;
  1027. $this->style->FontSet();
  1028. return true;
  1029. }
  1030. /**
  1031. * balise : NOBREAK
  1032. * mode : OUVERTURE
  1033. *
  1034. * @param array param�tres de l'�l�ment de parsing
  1035. * @return null
  1036. */
  1037. function o_NOBREAK($param)
  1038. {
  1039. if ($this->forOneLine) return false;
  1040. $this->maxH = 0;
  1041. // on extrait tout ce qui est contenu dans le NOBREAK
  1042. $res = $this->parsing->getLevel($this->parse_pos);
  1043. // on en cr�� un sous HTML que l'on transforme en PDF
  1044. // pour analyse les dimensions
  1045. // et voir si ca rentre
  1046. $sub = null;
  1047. $this->CreateSubHTML($sub);
  1048. $sub->writeHTML($res[1]);
  1049. $y = $this->pdf->getY();
  1050. if (
  1051. $sub->maxY < ($this->pdf->h - $this->pdf->tMargin-$this->pdf->bMargin) &&
  1052. $y + $sub->maxY>=($this->pdf->h - $this->pdf->bMargin)
  1053. )
  1054. $this->setNewPage();
  1055. unset($sub);
  1056. return true;
  1057. }
  1058. /**
  1059. * balise : NOBREAK
  1060. * mode : FERMETURE
  1061. *
  1062. * @param array param�tres de l'�l�ment de parsing
  1063. * @return null
  1064. */
  1065. function c_NOBREAK($param)
  1066. {
  1067. if ($this->forOneLine) return false;
  1068. $this->maxH = 0;
  1069. return true;
  1070. }
  1071. /**
  1072. * balise : DIV
  1073. * mode : OUVERTURE
  1074. *
  1075. * @param array param�tres de l'�l�ment de parsing
  1076. * @return null
  1077. */
  1078. function o_DIV($param, $other = 'div')
  1079. {
  1080. if ($this->forOneLine) return false;
  1081. $this->style->save();
  1082. $this->style->analyse($other, $param);
  1083. $this->style->FontSet();
  1084. $align_object = null;
  1085. if ($this->style->value['margin-auto']) $align_object = 'center';
  1086. $marge = array();
  1087. $marge['l'] = $this->style->value['border']['l']['width'] + $this->style->value['padding']['l']+0.03;
  1088. $marge['r'] = $this->style->value['border']['r']['width'] + $this->style->value['padding']['r']+0.03;
  1089. $marge['t'] = $this->style->value['border']['t']['width'] + $this->style->value['padding']['t']+0.03;
  1090. $marge['b'] = $this->style->value['border']['b']['width'] + $this->style->value['padding']['b']+0.03;
  1091. // on extrait tout ce qui est contenu dans la DIV
  1092. $res = $this->parsing->getLevel($this->parse_pos);
  1093. // on en cr�� un sous HTML que l'on transforme en PDF
  1094. // pour analyse les dimensions
  1095. $w = 0; $h = 0;
  1096. if (trim($res[1]))
  1097. {
  1098. $sub = null;
  1099. $this->CreateSubHTML($sub);
  1100. $sub->writeHTML($res[1]);
  1101. $w = $sub->maxX;
  1102. $h = $sub->maxY;
  1103. unset($sub);
  1104. }
  1105. if (($w==0 && $this->style->value['width']==0) || $this->style->value['position']=='absolute')
  1106. {
  1107. $w+= $marge['l']+$marge['r']+0.001;
  1108. }
  1109. $h+= $marge['t']+$marge['b']+0.001;
  1110. $this->style->value['width'] = max($w, $this->style->value['width']);
  1111. $this->style->value['height'] = max($h, $this->style->value['height']);
  1112. if (!$this->style->value['position'])
  1113. {
  1114. if (
  1115. $this->style->value['width'] < ($this->pdf->w - $this->pdf->lMargin-$this->pdf->rMargin) &&
  1116. $this->pdf->x + $this->style->value['width']>=($this->pdf->w - $this->pdf->rMargin)
  1117. )
  1118. $this->o_BR(array());
  1119. if (
  1120. $this->style->value['height'] < ($this->pdf->h - $this->pdf->tMargin-$this->pdf->bMargin) &&
  1121. $this->pdf->y + $this->style->value['height']>=($this->pdf->h - $this->pdf->bMargin)
  1122. )
  1123. $this->setNewPage();
  1124. // en cas d'alignement => correction
  1125. $w = $this->style->value['width'];
  1126. $old = isset($this->style->table[count($this->style->table)-1]) ? $this->style->table[count($this->style->table)-1] : $this->style->value;
  1127. $parent_w = $old['width'] ? $old['width'] : $this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin;
  1128. if ($parent_w>$w)
  1129. {
  1130. if ($align_object=='center') $this->pdf->x = $this->pdf->x + ($parent_w-$w)*0.5;
  1131. else if ($align_object=='right') $this->pdf->x = $this->pdf->x + $parent_w-$w;
  1132. }
  1133. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1134. }
  1135. else
  1136. {
  1137. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1138. $this->saveMax();
  1139. $this->saveX = 0;
  1140. $this->saveY = 0;
  1141. $this->saveH = 0;
  1142. }
  1143. // initialisation du style des bordures de la premiere partie de tableau
  1144. $this->Rectangle(
  1145. $this->style->value['x'],
  1146. $this->style->value['y'],
  1147. $this->style->value['width'],
  1148. $this->style->value['height'],
  1149. $this->style->value['border'],
  1150. $this->style->value['padding'],
  1151. 0,
  1152. $this->style->value['background']
  1153. );
  1154. $marge = array();
  1155. $marge['l'] = $this->style->value['border']['l']['width'] + $this->style->value['padding']['l']+0.03;
  1156. $marge['r'] = $this->style->value['border']['r']['width'] + $this->style->value['padding']['r']+0.03;
  1157. $marge['t'] = $this->style->value['border']['t']['width'] + $this->style->value['padding']['t']+0.03;
  1158. $marge['b'] = $this->style->value['border']['b']['width'] + $this->style->value['padding']['b']+0.03;
  1159. $this->style->value['width'] = $this->style->value['width']-$marge['l']-$marge['r'];
  1160. $this->style->value['height'] = $this->style->value['height']-$marge['r']-$marge['b'];
  1161. // limitation des marges aux dimensions de la div
  1162. $mL = $this->style->value['x']+$marge['l'];
  1163. $mR = $this->pdf->w - $mL - $this->style->value['width'];
  1164. $this->saveMargin($mL, 0, $mR);
  1165. // positionnement en fonction
  1166. $h_corr = $this->style->value['height'];
  1167. $h_reel = $h-$marge['b']-$marge['t'];
  1168. switch($this->style->value['vertical-align'])
  1169. {
  1170. case 'bottom':
  1171. $y_corr = $h_corr-$h_reel;
  1172. break;
  1173. case 'middle':
  1174. $y_corr = ($h_corr-$h_reel)*0.5;
  1175. break;
  1176. case 'top':
  1177. default:
  1178. $y_corr = 0;
  1179. break;
  1180. }
  1181. $this->pdf->setX($this->style->value['x']+$marge['l']);
  1182. $this->pdf->setY($this->style->value['y']+$marge['t']+$y_corr);
  1183. $this->setNewPositionForNewLine();
  1184. return true;
  1185. }
  1186. function o_BLOCKQUOTE($param) { return $this->o_DIV($param, 'blockquote'); }
  1187. /**
  1188. * balise : DIV
  1189. * mode : FERMETURE
  1190. *
  1191. * @param array param�tres de l'�l�ment de parsing
  1192. * @return null
  1193. */
  1194. function c_DIV($param)
  1195. {
  1196. if ($this->forOneLine) return false;
  1197. $marge = array();
  1198. $marge['l'] = $this->style->value['border']['l']['width'] + $this->style->value['padding']['l']+0.03;
  1199. $marge['r'] = $this->style->value['border']['r']['width'] + $this->style->value['padding']['r']+0.03;
  1200. $marge['t'] = $this->style->value['border']['t']['width'] + $this->style->value['padding']['t']+0.03;
  1201. $marge['b'] = $this->style->value['border']['b']['width'] + $this->style->value['padding']['b']+0.03;
  1202. $x = $this->style->value['x'];
  1203. $y = $this->style->value['y'];
  1204. $w = $this->style->value['width']+$marge['l']+$marge['r'];
  1205. $h = $this->style->value['height']+$marge['t']+$marge['b'];
  1206. // correction pour les margins
  1207. $w+= $this->style->value['margin']['r'];
  1208. $h+= $this->style->value['margin']['b'];
  1209. if ($this->style->value['position']!='absolute')
  1210. {
  1211. // position
  1212. $this->pdf->x = $x+$w;
  1213. $this->pdf->y = $y;
  1214. // position MAX
  1215. $this->maxX = max($this->maxX, $x+$w);
  1216. $this->maxY = max($this->maxY, $y+$h);
  1217. $this->maxH = max($this->maxH, $h);
  1218. }
  1219. else
  1220. {
  1221. // position
  1222. $this->pdf->x = $this->style->value['xc'];
  1223. $this->pdf->y = $this->style->value['yc'];
  1224. $this->loadMax();
  1225. }
  1226. $block = ($this->style->value['display']!='inline' && $this->style->value['position']!='absolute');
  1227. $this->style->load();
  1228. $this->style->FontSet();
  1229. $this->loadMargin();
  1230. if ($block) $this->o_BR(array());
  1231. return true;
  1232. }
  1233. function c_BLOCKQUOTE($param) { return $this->c_DIV($param); }
  1234. /**
  1235. * balise : BARCODE
  1236. * mode : OUVERTURE
  1237. *
  1238. * @param array param�tres de l'�l�ment de parsing
  1239. * @return null
  1240. */
  1241. function o_BARCODE($param)
  1242. {
  1243. $lst_barcode = array(
  1244. 'EAN13' => '0.35mm',
  1245. 'UPC_A' => '0.35mm',
  1246. 'CODE39' => '1.00mm',
  1247. );
  1248. if (isset($param['type'])) $param['type'] = strtoupper($param['type']);
  1249. if (!isset($param['type']) || !isset($lst_barcode[$param['type']])) $param['type']=='CODE39';
  1250. if (!isset($param['value'])) $param['value'] = 0;
  1251. if (!isset($param['bar_w'])) $param['bar_w'] = $lst_barcode[$param['type']];
  1252. if (!isset($param['bar_h'])) $param['bar_h'] = '10mm';
  1253. if (!isset($param['style']['color'])) $param['style']['color'] = '#000000';
  1254. $param['style']['background-color'] = $param['style']['color'];
  1255. $this->style->save();
  1256. $this->style->analyse('barcode', $param);
  1257. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1258. $this->style->FontSet();
  1259. $x = $this->pdf->getX();
  1260. $y = $this->pdf->getY();
  1261. $w = $this->style->ConvertToMM($param['bar_w']);
  1262. $h = $this->style->ConvertToMM($param['bar_h']);
  1263. $infos = $this->pdf->{'BARCODE_'.$param['type']}($x, $y, $param['value'], $h, $w);
  1264. // position maximale globale
  1265. $this->maxX = max($this->maxX, $x+$infos[0]);
  1266. $this->maxY = max($this->maxY, $y+$infos[1]);
  1267. $this->maxH = max($this->maxH, $infos[1]);
  1268. $this->pdf->setX($x+$infos[0]);
  1269. $this->style->load();
  1270. $this->style->FontSet();
  1271. return true;
  1272. }
  1273. /**
  1274. * balise : BARCODE
  1275. * mode : FERMETURE
  1276. *
  1277. * @param array param�tres de l'�l�ment de parsing
  1278. * @return null
  1279. */
  1280. function c_BARCODE($param)
  1281. {
  1282. // completement inutile
  1283. return true;
  1284. }
  1285. /**
  1286. * balise : BOOKMARK
  1287. * mode : OUVERTURE
  1288. *
  1289. * @param array param�tres de l'�l�ment de parsing
  1290. * @return null
  1291. */
  1292. function o_BOOKMARK($param)
  1293. {
  1294. $titre = isset($param['title']) ? trim($param['title']) : '';
  1295. $level = isset($param['level']) ? floor($param['level']) : 0;
  1296. if ($level<0) $level = 0;
  1297. if ($titre) $this->pdf->Bookmark($titre, $level, -1);
  1298. return true;
  1299. }
  1300. /**
  1301. * balise : BOOKMARK
  1302. * mode : FERMETURE
  1303. *
  1304. * @param array param�tres de l'�l�ment de parsing
  1305. * @return null
  1306. */
  1307. function c_BOOKMARK($param)
  1308. {
  1309. // completement inutile
  1310. return true;
  1311. }
  1312. /**
  1313. * balise : WRITE
  1314. * mode : OUVERTURE
  1315. *
  1316. * @param array param�tres de l'�l�ment de parsing
  1317. * @return null
  1318. */
  1319. function o_WRITE($param)
  1320. {
  1321. $fill = ($this->style->value['background']['color']!==null && $this->style->value['background']['image']===null);
  1322. // r�cup�ration du texte � �crire, et conversion
  1323. $txt = $param['txt'];
  1324. $txt = str_replace('&euro;', '�', $txt);
  1325. if ($this->isAfterFloat)
  1326. {
  1327. $txt = preg_replace('/^([\s]*)([^\s])/isU', '$2', $txt);
  1328. $this->isAfterFloat = false;
  1329. }
  1330. $txt = html_entity_decode($txt, ENT_QUOTES, 'ISO-8859-15');
  1331. $txt = str_replace('[[page_cu]]', $this->pdf->PageNo(), $txt);
  1332. // tailles du texte
  1333. $h = 1.08*$this->style->value['font-size'];
  1334. $dh = $h*$this->style->value['mini-decal'];
  1335. $w = $this->pdf->GetStringWidth($txt);
  1336. // identification de l'alignement
  1337. $align = 'L';
  1338. if ($this->style->value['text-align']=='li_right')
  1339. {
  1340. $w = $this->style->value['width'];
  1341. $align = 'R';
  1342. }
  1343. $curr_max = strlen($txt); // taille maxi du texte
  1344. $maxX = 0; // plus grande largeur du texte apres retour � la ligne
  1345. $x = $this->pdf->getX(); // position du texte
  1346. $y = $this->pdf->getY();
  1347. $w = $this->pdf->GetStringWidth($txt); // largeur du texte
  1348. list($left, $right) = $this->getMargins($y); // marges autorisees
  1349. $nb = 0; // nbr de lignes d�coup�es
  1350. // tant que ca ne rentre pas sur la ligne et qu'on a du texte => on d�coupe
  1351. while($x+$w>$right && $x<$right && strlen($txt))
  1352. {
  1353. // liste des mots
  1354. $lst = explode(' ', $txt);
  1355. // trouver une phrase qui rentre dans la largeur, en ajoutant les mots 1 � 1
  1356. $i=0;
  1357. $old = '';
  1358. $str = $lst[0];
  1359. while(($x+$this->pdf->GetStringWidth($str))<$right)
  1360. {
  1361. unset($lst[$i]);
  1362. $old = $str;
  1363. $i++;
  1364. $str.= ' '.$lst[$i];
  1365. }
  1366. $str = $old;
  1367. // si rien de rentre, et que le premier mot ne rentre de toute facon pas dans une ligne, on le force...
  1368. if ($i==0 && (($left+$this->pdf->GetStringWidth($lst[0]))>=$right))
  1369. {
  1370. $str = $lst[0];
  1371. unset($lst[0]);
  1372. }
  1373. // r�cup�ration des mots restant, et calcul de la largeur
  1374. $txt = implode(' ', $lst);
  1375. $w = $this->pdf->GetStringWidth($str);
  1376. // ecriture du bout de phrase extrait et qui rentre
  1377. $wc = ($align=='L' ? $w : $this->style->value['width']);
  1378. if ($right - $left<$wc) $wc = $right - $left;
  1379. if (strlen($str)) $this->pdf->Cell($wc, $h+$dh, $str, 0, 0, $align, $fill, $this->inLink);
  1380. $this->maxH = max($this->maxH, $this->style->getLineHeight());
  1381. // d�termination de la largeur max
  1382. $maxX = max($maxX, $this->pdf->getX());
  1383. // nouvelle position et nouvelle largeur pour la boucle
  1384. $w = $this->pdf->GetStringWidth($txt);
  1385. $y = $this->pdf->getY();
  1386. $x = $this->pdf->getX();
  1387. // si il reste du text � afficher
  1388. if (strlen($txt))
  1389. {
  1390. if ($this->forOneLine)
  1391. {
  1392. $this->maxX = max($this->maxX, $maxX);
  1393. return false;
  1394. }
  1395. // retour � la ligne
  1396. $this->o_BR(array('style' => ''), $curr_max - strlen($txt));
  1397. $y = $this->pdf->getY();
  1398. $x = $this->pdf->getX();
  1399. // si la prochaine ligne ne rentre pas dans la page => nouvelle page
  1400. if ($y + $h>$this->pdf->h - $this->pdf->bMargin) $this->setNewPage('', null, $curr_max - strlen($txt));
  1401. // ligne supl�mentaire. au bout de 1000 : trop long => erreur
  1402. $nb++;
  1403. if ($nb>1000) @HTML2PDF::makeError(2, __FILE__, __LINE__, array($txt, $right-$left, $this->pdf->GetStringWidth($txt)));
  1404. list($left, $right) = $this->getMargins($y); // marges autorisees
  1405. }
  1406. }
  1407. // si il reste du text apres d�coupe, c'est qu'il rentre direct => on l'affiche
  1408. if (strlen($txt))
  1409. {
  1410. $this->pdf->Cell(($align=='L' ? $w : $this->style->value['width']), $h+$dh, $txt, 0, 0, $align, $fill, $this->inLink);
  1411. $this->maxH = max($this->maxH, $this->style->getLineHeight());
  1412. }
  1413. // d�termination des positions MAX
  1414. $maxX = max($maxX, $this->pdf->getX());
  1415. $maxY = $this->pdf->getY()+$h;
  1416. // position maximale globale
  1417. $this->maxX = max($this->maxX, $maxX);
  1418. $this->maxY = max($this->maxY, $maxY);
  1419. return true;
  1420. }
  1421. /**
  1422. * tracer une image
  1423. *
  1424. * @param string nom du fichier source
  1425. * @return null
  1426. */
  1427. function Image($src, $sub_li=false)
  1428. {
  1429. // est-ce que c'est une image ?
  1430. $infos=@GetImageSize($src);
  1431. if (count($infos)<2)
  1432. {
  1433. @HTML2PDF::makeError(6, __FILE__, __LINE__, $src);
  1434. return false;
  1435. }
  1436. // r�cup�ration des dimensions dans l'unit� du PDF
  1437. $wi = $infos[0]/$this->pdf->k;
  1438. $hi = $infos[1]/$this->pdf->k;
  1439. // d�termination des dimensions d'affichage en fonction du style
  1440. if ($this->style->value['width'] && $this->style->value['height'])
  1441. {
  1442. $w = $this->style->value['width'];
  1443. $h = $this->style->value['height'];
  1444. }
  1445. else if ($this->style->value['width'])
  1446. {
  1447. $w = $this->style->value['width'];
  1448. $h = $hi*$w/$wi;
  1449. }
  1450. else if ($this->style->value['height'])
  1451. {
  1452. $h = $this->style->value['height'];
  1453. $w = $wi*$h/$hi;
  1454. }
  1455. else
  1456. {
  1457. $w = 72./96.*$wi;
  1458. $h = 72./96.*$hi;
  1459. }
  1460. // detection du float
  1461. $float = $this->style->getFloat();
  1462. if ($float && $this->maxH) $this->o_BR(array());
  1463. // position d'affichage
  1464. $x = $this->pdf->getX();
  1465. $y = $this->pdf->getY();
  1466. // si l'image ne rentre pas dans la ligne => nouvelle ligne
  1467. if (!$float && ($x + $w>$this->pdf->w - $this->pdf->rMargin))
  1468. {
  1469. $hnl = $this->style->getLineHeight();
  1470. $hnl = max($this->maxH, $hnl);
  1471. $this->setNewLine($hnl);
  1472. $x = $this->pdf->getX();
  1473. $y = $this->pdf->getY();
  1474. }
  1475. // si l'image ne rentre pas dans la page => nouvelle page
  1476. if ($y + $h>$this->pdf->h - $this->pdf->bMargin)
  1477. {
  1478. $this->setNewPage();
  1479. $x = $this->pdf->getX();
  1480. $y = $this->pdf->getY();
  1481. }
  1482. // correction pour l'affichage d'une puce image
  1483. $hT = 0.80*$this->style->value['font-size'];
  1484. if ($sub_li && $h<$hT)
  1485. {
  1486. $y+=($hT-$h);
  1487. }
  1488. $yc = $y-$this->style->value['margin']['t'];
  1489. // d�termination de la position r�elle d'affichage en fonction du text-align du parent
  1490. $old = isset($this->style->table[count($this->style->table)-1]) ? $this->style->table[count($this->style->table)-1] : $this->style->value;
  1491. if ( $old['width'])
  1492. {
  1493. $parent_w = $old['width'];
  1494. $parent_x = $x;
  1495. }
  1496. else
  1497. {
  1498. $parent_w = $this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin;
  1499. $parent_x = $this->pdf->lMargin;
  1500. }
  1501. if ($float)
  1502. {
  1503. list($lx, $rx) = $this->getMargins($yc);
  1504. $parent_x = $lx;
  1505. $parent_w = $rx-$lx;
  1506. }
  1507. if ($parent_w>$w && $float!='left')
  1508. {
  1509. if ($float=='right' || $this->style->value['text-align']=='li_right') $x = $parent_x + $parent_w - $w-$this->style->value['margin']['r']-$this->style->value['margin']['l'];
  1510. }
  1511. // affichage de l'image, et positionnement � la suite
  1512. if (!$this->sub_part && !$this->isSubPart) $this->pdf->Image($src, $x, $y, $w, $h, '', $this->inLink);
  1513. $x-= $this->style->value['margin']['l'];
  1514. $y-= $this->style->value['margin']['t'];
  1515. $w+= $this->style->value['margin']['l'] + $this->style->value['margin']['r'];
  1516. $h+= $this->style->value['margin']['t'] + $this->style->value['margin']['b'];
  1517. if ($float=='left')
  1518. {
  1519. $this->maxX = max($this->maxX, $x+$w);
  1520. $this->maxY = max($this->maxY, $y+$h);
  1521. $this->addMargins($float, $x, $y, $x+$w, $y+$h);
  1522. list($lx, $rx) = $this->getMargins($yc);
  1523. $this->pdf->x = $lx;
  1524. $this->pdf->y = $yc;
  1525. }
  1526. else if ($float=='right')
  1527. {
  1528. // $this->maxX = max($this->maxX, $x+$w);
  1529. $this->maxY = max($this->maxY, $y+$h);
  1530. $this->addMargins($float, $x, $y, $x+$w, $y+$h);
  1531. list($lx, $rx) = $this->getMargins($yc);
  1532. $this->pdf->x = $lx;
  1533. $this->pdf->y = $yc;
  1534. }
  1535. else
  1536. {
  1537. $this->pdf->SetX($x+$w);
  1538. $this->maxX = max($this->maxX, $x+$w);
  1539. $this->maxY = max($this->maxY, $y+$h);
  1540. $this->maxH = max($this->maxH, $h);
  1541. }
  1542. }
  1543. /**
  1544. * Tracer un rectanble
  1545. *
  1546. * @param float position X
  1547. * @param float position Y
  1548. * @param float Largeur
  1549. * @param float Hauteur
  1550. * @param array Tableau de style de d�finition des borders
  1551. * @param float padding - marge int�rieur au rectangle => non utile mais on le passe en param�tre
  1552. * @param float margin - marge exterieur au rectangle
  1553. * @param array Tableau de style de d�finition du background
  1554. * @return null
  1555. */
  1556. function Rectangle($x, $y, $w, $h, $border, $padding, $margin, $background)
  1557. {
  1558. if ($this->sub_part || $this->isSubPart) return false;
  1559. if ($h===null) return false;
  1560. $x+= $margin;
  1561. $y+= $margin;
  1562. $w-= $margin*2;
  1563. $h-= $margin*2;
  1564. // r�cup�ration des radius
  1565. $radius_h = $border['radius'][0];
  1566. $radius_v = $border['radius'][1];
  1567. // verification des coins en radius
  1568. $coin_TL = ($radius_h && $radius_v && $radius_v>$border['t']['width'] && $radius_h>$border['l']['width']) ? array($radius_h, $radius_v) : null;
  1569. $coin_TR = ($radius_h && $radius_v && $radius_v>$border['t']['width'] && $radius_h>$border['r']['width']) ? array($radius_h, $radius_v) : null;
  1570. $coin_BL = ($radius_h && $radius_v && $radius_v>$border['b']['width'] && $radius_h>$border['l']['width']) ? array($radius_h, $radius_v) : null;
  1571. $coin_BR = ($radius_h && $radius_v && $radius_v>$border['b']['width'] && $radius_h>$border['r']['width']) ? array($radius_h, $radius_v) : null;
  1572. // traitement de la couleur de fond
  1573. $STYLE = '';
  1574. if ($background['color'])
  1575. {
  1576. $this->pdf->SetFillColor($background['color'][0], $background['color'][1], $background['color'][2]);
  1577. $STYLE.= 'F';
  1578. }
  1579. if ($STYLE)
  1580. {
  1581. $this->pdf->clippingPathOpen($x, $y, $w, $h, $coin_TL,$coin_TR, $coin_BL, $coin_BR);
  1582. $this->pdf->Rect($x, $y, $w, $h, $STYLE);
  1583. $this->pdf->clippingPathClose();
  1584. }
  1585. // traitement de l'image de fond
  1586. if ($background['image'])
  1587. {
  1588. $i_name = $background['image'];
  1589. $i_position = $background['position']!==null ? $background['position'] : array(0, 0);
  1590. $i_repeat = $background['repeat']!==null ? $background['repeat'] : array(true, true);
  1591. // taile du fond (il faut retirer les borders
  1592. $b_x = $x;
  1593. $b_y = $y;
  1594. $b_w = $w;
  1595. $b_h = $h;
  1596. if ($border['b']['width']) { $b_h-= $border['b']['width']; }
  1597. if ($border['l']['width']) { $b_w-= $border['l']['width']; $b_x+= $border['l']['width']; }
  1598. if ($border['t']['width']) { $b_h-= $border['t']['width']; $b_y+= $border['t']['width']; }
  1599. if ($border['r']['width']) { $b_w-= $border['r']['width']; }
  1600. // est-ce que c'est une image ?
  1601. $i_infos=@GetImageSize($i_name);
  1602. if (count($i_infos)<2)
  1603. {
  1604. @HTML2PDF::makeError(6, __FILE__, __LINE__, $i_name);
  1605. return false;
  1606. }
  1607. // r�cup�ration des dimensions dans l'unit� du PDF
  1608. $i_width = 72./96.*$i_infos[0]/$this->pdf->k;
  1609. $i_height = 72./96.*$i_infos[1]/$this->pdf->k;
  1610. if ($i_repeat[0]) $i_position[0] = $b_x;
  1611. else if(preg_match('/^([-]?[0-9\.]+)%/isU', $i_position[0], $match)) $i_position[0] = $b_x + $match[1]*($b_w-$i_width)/100;
  1612. else $i_position[0] = $b_x+$i_position[0];
  1613. if ($i_repeat[1]) $i_position[1] = $b_y;
  1614. else if(preg_match('/^([-]?[0-9\.]+)%/isU', $i_position[1], $match)) $i_position[1] = $b_y + $match[1]*($b_h-$i_height)/100;
  1615. else $i_position[1] = $b_y+$i_position[1];
  1616. $i_x_min = $b_x;
  1617. $i_x_max = $b_x+$b_w;
  1618. $i_y_min = $b_y;
  1619. $i_y_max = $b_y+$b_h;
  1620. if (!$i_repeat[0] && !$i_repeat[1])
  1621. {
  1622. $i_x_min = $i_position[0]; $i_x_max = $i_position[0]+$i_width;
  1623. $i_y_min = $i_position[1]; $i_y_max = $i_position[1]+$i_height;
  1624. }
  1625. else if ($i_repeat[0] && !$i_repeat[1])
  1626. {
  1627. $i_y_min = $i_position[1]; $i_y_max = $i_position[1]+$i_height;
  1628. }
  1629. elseif (!$i_repeat[0] && $i_repeat[1])
  1630. {
  1631. $i_x_min = $i_position[0]; $i_x_max = $i_position[0]+$i_width;
  1632. }
  1633. if (is_array($coin_TL)) { $coin_TL[0]-= $border['l']['width']; $coin_TL[1]-= $border['t']['width']; }
  1634. if (is_array($coin_TR)) { $coin_TR[0]-= $border['r']['width']; $coin_TR[1]-= $border['t']['width']; }
  1635. if (is_array($coin_BL)) { $coin_BL[0]-= $border['l']['width']; $coin_BL[1]-= $border['b']['width']; }
  1636. if (is_array($coin_BR)) { $coin_BR[0]-= $border['r']['width']; $coin_BR[1]-= $border['b']['width']; }
  1637. $this->pdf->clippingPathOpen($b_x, $b_y, $b_w, $b_h, $coin_TL, $coin_TR, $coin_BL, $coin_BR);
  1638. for ($i_y=$i_y_min; $i_y<$i_y_max; $i_y+=$i_height)
  1639. {
  1640. for ($i_x=$i_x_min; $i_x<$i_x_max; $i_x+=$i_width)
  1641. {
  1642. $c_x = null;
  1643. $c_y = null;
  1644. $c_w = $i_width;
  1645. $c_h = $i_height;
  1646. if ($i_y_max-$i_y<$i_height)
  1647. {
  1648. $c_x = $i_x;
  1649. $c_y = $i_y;
  1650. $c_h = $i_y_max-$i_y;
  1651. }
  1652. if ($i_x_max-$i_x<$i_width)
  1653. {
  1654. $c_x = $i_x;
  1655. $c_y = $i_y;
  1656. $c_w = $i_x_max-$i_x;
  1657. }
  1658. $this->pdf->Image($i_name, $i_x, $i_y, $i_width, $i_height, '', '');
  1659. }
  1660. }
  1661. $this->pdf->clippingPathClose();
  1662. }
  1663. $x-= 0.01;
  1664. $y-= 0.01;
  1665. $w+= 0.02;
  1666. $h+= 0.02;
  1667. if ($border['b']['width']) $border['b']['width']+= 0.02;
  1668. if ($border['l']['width']) $border['l']['width']+= 0.02;
  1669. if ($border['t']['width']) $border['t']['width']+= 0.02;
  1670. if ($border['r']['width']) $border['r']['width']+= 0.02;
  1671. if ($border['b']['width'] && $border['b']['color'][0]!==null)
  1672. {
  1673. $pt = array();
  1674. $pt[] = $x+$w; $pt[] = $y+$h;
  1675. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h;
  1676. $pt[] = $x+$border['l']['width']; $pt[] = $y+$h;
  1677. $pt[] = $x; $pt[] = $y+$h;
  1678. $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width'];
  1679. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
  1680. $bord = 3;
  1681. if (is_array($coin_BL))
  1682. {
  1683. $bord-=2;
  1684. $pt[4] += $radius_h-$border['l']['width'];
  1685. $pt[8] += $radius_h-$border['l']['width'];
  1686. unset($pt[6]);unset($pt[7]);
  1687. }
  1688. if (is_array($coin_BR))
  1689. {
  1690. $courbe = array();
  1691. $courbe[] = $x+$w; $courbe[] = $y+$h-$radius_v;
  1692. $courbe[] = $x+$w-$radius_h; $courbe[] = $y+$h;
  1693. $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$h-$radius_v;
  1694. $courbe[] = $x+$w-$radius_h; $courbe[] = $y+$h-$border['b']['width'];
  1695. $courbe[] = $x+$w-$radius_h; $courbe[] = $y+$h-$radius_v;
  1696. $this->Courbe($courbe, $border['b']['color']);
  1697. $bord-=1;
  1698. $pt[2] -= $radius_h-$border['r']['width'];
  1699. $pt[10]-= $radius_h-$border['r']['width'];
  1700. unset($pt[0]);unset($pt[1]);
  1701. }
  1702. $pt = array_values($pt);
  1703. $this->Line($pt, $border['b']['color'], $border['b']['type'], $border['b']['width'], $bord);
  1704. }
  1705. if ($border['l']['width'] && $border['l']['color'][0]!==null)
  1706. {
  1707. $pt = array();
  1708. $pt[] = $x; $pt[] = $y+$h;
  1709. $pt[] = $x; $pt[] = $y+$h-$border['b']['width'];
  1710. $pt[] = $x; $pt[] = $y+$border['t']['width'];
  1711. $pt[] = $x; $pt[] = $y;
  1712. $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width'];
  1713. $pt[] = $x+$border['l']['width']; $pt[] = $y+$h-$border['b']['width'];
  1714. $bord = 3;
  1715. if (is_array($coin_BL))
  1716. {
  1717. $courbe = array();
  1718. $courbe[] = $x+$radius_h; $courbe[] = $y+$h;
  1719. $courbe[] = $x; $courbe[] = $y+$h-$radius_v;
  1720. $courbe[] = $x+$radius_h; $courbe[] = $y+$h-$border['b']['width'];
  1721. $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$h-$radius_v;
  1722. $courbe[] = $x+$radius_h; $courbe[] = $y+$h-$radius_v;
  1723. $this->Courbe($courbe, $border['l']['color']);
  1724. $bord-=1;
  1725. $pt[3] -= $radius_v-$border['b']['width'];
  1726. $pt[11]-= $radius_v-$border['b']['width'];
  1727. unset($pt[0]);unset($pt[1]);
  1728. }
  1729. if (is_array($coin_TL))
  1730. {
  1731. $bord-=2;
  1732. $pt[5] += $radius_v-$border['t']['width'];
  1733. $pt[9] += $radius_v-$border['t']['width'];
  1734. unset($pt[6]);unset($pt[7]);
  1735. }
  1736. $pt = array_values($pt);
  1737. $this->Line($pt, $border['l']['color'], $border['l']['type'], $border['l']['width'], $bord);
  1738. }
  1739. if ($border['t']['width'] && $border['t']['color'][0]!==null)
  1740. {
  1741. $pt = array();
  1742. $pt[] = $x; $pt[] = $y;
  1743. $pt[] = $x+$border['l']['width']; $pt[] = $y;
  1744. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y;
  1745. $pt[] = $x+$w; $pt[] = $y;
  1746. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
  1747. $pt[] = $x+$border['l']['width']; $pt[] = $y+$border['t']['width'];
  1748. $bord = 3;
  1749. if (is_array($coin_TL))
  1750. {
  1751. $courbe = array();
  1752. $courbe[] = $x; $courbe[] = $y+$radius_v;
  1753. $courbe[] = $x+$radius_h; $courbe[] = $y;
  1754. $courbe[] = $x+$border['l']['width']; $courbe[] = $y+$radius_v;
  1755. $courbe[] = $x+$radius_h; $courbe[] = $y+$border['t']['width'];
  1756. $courbe[] = $x+$radius_h; $courbe[] = $y+$radius_v;
  1757. $this->Courbe($courbe, $border['t']['color']);
  1758. $bord-=1;
  1759. $pt[2] += $radius_h-$border['l']['width'];
  1760. $pt[10]+= $radius_h-$border['l']['width'];
  1761. unset($pt[0]);unset($pt[1]);
  1762. }
  1763. if (is_array($coin_TR))
  1764. {
  1765. $bord-=2;
  1766. $pt[4] -= $radius_h-$border['r']['width'];
  1767. $pt[8] -= $radius_h-$border['r']['width'];
  1768. unset($pt[6]);unset($pt[7]);
  1769. }
  1770. $pt = array_values($pt);
  1771. $this->Line($pt, $border['t']['color'], $border['t']['type'], $border['t']['width'], $bord);
  1772. }
  1773. if ($border['r']['width'] && $border['r']['color'][0]!==null)
  1774. {
  1775. $pt = array();
  1776. $pt[] = $x+$w; $pt[] = $y;
  1777. $pt[] = $x+$w; $pt[] = $y+$border['t']['width'];
  1778. $pt[] = $x+$w; $pt[] = $y+$h-$border['b']['width'];
  1779. $pt[] = $x+$w; $pt[] = $y+$h;
  1780. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$h-$border['b']['width'];
  1781. $pt[] = $x+$w-$border['r']['width']; $pt[] = $y+$border['t']['width'];
  1782. $bord = 3;
  1783. if (is_array($coin_TR))
  1784. {
  1785. $courbe = array();
  1786. $courbe[] = $x+$w-$radius_h; $courbe[] = $y;
  1787. $courbe[] = $x+$w; $courbe[] = $y+$radius_v;
  1788. $courbe[] = $x+$w-$radius_h; $courbe[] = $y+$border['t']['width'];
  1789. $courbe[] = $x+$w-$border['r']['width']; $courbe[] = $y+$radius_v;
  1790. $courbe[] = $x+$w-$radius_h; $courbe[] = $y+$radius_v;
  1791. $this->Courbe($courbe, $border['r']['color']);
  1792. $bord-=1;
  1793. $pt[3] += $radius_v-$border['t']['width'];
  1794. $pt[11]+= $radius_v-$border['t']['width'];
  1795. unset($pt[0]);unset($pt[1]);
  1796. }
  1797. if (is_array($coin_BR))
  1798. {
  1799. $bord-=2;
  1800. $pt[5] -= $radius_v-$border['b']['width'];
  1801. $pt[9] -= $radius_v-$border['b']['width'];
  1802. unset($pt[6]);unset($pt[7]);
  1803. }
  1804. $pt = array_values($pt);
  1805. $this->Line($pt, $border['r']['color'], $border['r']['type'], $border['r']['width'], $bord);
  1806. }
  1807. if ($background) $this->pdf->SetFillColor($background['color'][0], $background['color'][1], $background['color'][2]);
  1808. }
  1809. function Courbe($pt, $color)
  1810. {
  1811. $this->pdf->SetFillColor($color[0], $color[1], $color[2]);
  1812. $this->pdf->drawCourbe($pt[0], $pt[1], $pt[2], $pt[3], $pt[4], $pt[5], $pt[6], $pt[7], $pt[8], $pt[9]);
  1813. }
  1814. /**
  1815. * Tracer une ligne epaisse d�fini par ses points avec des extreminites en biseau
  1816. *
  1817. * @param array liste des points definissant le tour de la ligne
  1818. * @param float couleur RVB
  1819. * @param string type de ligne
  1820. * @param float largeur de la ligne
  1821. * @return null
  1822. */
  1823. function Line($pt, $color, $type, $width, $bord=3)
  1824. {
  1825. $this->pdf->SetFillColor($color[0], $color[1], $color[2]);
  1826. if ($type=='dashed' || $type=='dotted')
  1827. {
  1828. if ($bord==1)
  1829. {
  1830. $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
  1831. $this->pdf->Polygon($tmp, 'F');
  1832. $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
  1833. $pt = $tmp;
  1834. }
  1835. else if ($bord==2)
  1836. {
  1837. $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7];
  1838. $this->pdf->Polygon($tmp, 'F');
  1839. $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
  1840. $pt = $tmp;
  1841. }
  1842. else if ($bord==3)
  1843. {
  1844. $tmp = array(); $tmp[]=$pt[0]; $tmp[]=$pt[1]; $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
  1845. $this->pdf->Polygon($tmp, 'F');
  1846. $tmp = array(); $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[6]; $tmp[]=$pt[7]; $tmp[]=$pt[8]; $tmp[]=$pt[9];
  1847. $this->pdf->Polygon($tmp, 'F');
  1848. $tmp = array(); $tmp[]=$pt[2]; $tmp[]=$pt[3]; $tmp[]=$pt[4]; $tmp[]=$pt[5]; $tmp[]=$pt[8]; $tmp[]=$pt[9]; $tmp[]=$pt[10]; $tmp[]=$pt[11];
  1849. $pt = $tmp;
  1850. }
  1851. if ($pt[2]==$pt[0])
  1852. {
  1853. $l = abs(($pt[3]-$pt[1])*0.5);
  1854. $px = 0;
  1855. $py = $width;
  1856. $x1 = $pt[0]; $y1 = ($pt[3]+$pt[1])*0.5;
  1857. $x2 = $pt[6]; $y2 = ($pt[7]+$pt[5])*0.5;
  1858. }
  1859. else
  1860. {
  1861. $l = abs(($pt[2]-$pt[0])*0.5);
  1862. $px = $width;
  1863. $py = 0;
  1864. $x1 = ($pt[2]+$pt[0])*0.5; $y1 = $pt[1];
  1865. $x2 = ($pt[6]+$pt[4])*0.5; $y2 = $pt[7];
  1866. }
  1867. if ($type=='dashed')
  1868. {
  1869. $px = $px*3.;
  1870. $py = $py*3.;
  1871. }
  1872. $mode = ($l/($px+$py)<.5);
  1873. for($i=0; $l-($px+$py)*($i-0.5)>0; $i++)
  1874. {
  1875. if (($i%2)==$mode)
  1876. {
  1877. $j = $i-0.5;
  1878. $lx1 = $px*($j); if ($lx1<-$l) $lx1 =-$l;
  1879. $ly1 = $py*($j); if ($ly1<-$l) $ly1 =-$l;
  1880. $lx2 = $px*($j+1); if ($lx2>$l) $lx2 = $l;
  1881. $ly2 = $py*($j+1); if ($ly2>$l) $ly2 = $l;
  1882. $tmp = array();
  1883. $tmp[] = $x1+$lx1; $tmp[] = $y1+$ly1;
  1884. $tmp[] = $x1+$lx2; $tmp[] = $y1+$ly2;
  1885. $tmp[] = $x2+$lx2; $tmp[] = $y2+$ly2;
  1886. $tmp[] = $x2+$lx1; $tmp[] = $y2+$ly1;
  1887. $this->pdf->Polygon($tmp, 'F');
  1888. if ($j>0)
  1889. {
  1890. $tmp = array();
  1891. $tmp[] = $x1-$lx1; $tmp[] = $y1-$ly1;
  1892. $tmp[] = $x1-$lx2; $tmp[] = $y1-$ly2;
  1893. $tmp[] = $x2-$lx2; $tmp[] = $y2-$ly2;
  1894. $tmp[] = $x2-$lx1; $tmp[] = $y2-$ly1;
  1895. $this->pdf->Polygon($tmp, 'F');
  1896. }
  1897. }
  1898. }
  1899. }
  1900. else if ($type=='solid')
  1901. {
  1902. $this->pdf->Polygon($pt, 'F');
  1903. }
  1904. }
  1905. /**
  1906. * balise : BR
  1907. * mode : OUVERTURE
  1908. *
  1909. * @param array param�tres de l'�l�ment de parsing
  1910. * @param integer position reelle courante si saut de ligne pendant l'ecriture d'un texte
  1911. * @return null
  1912. */
  1913. function o_BR($param, $curr = null)
  1914. {
  1915. if ($this->forOneLine) return false;
  1916. $h = $this->style->getLineHeight();
  1917. $h = max($this->maxH, $h);
  1918. $y = $this->pdf->getY();
  1919. // si la ligne est vide, la position maximale n'a pas �t� mise � jour => on la met � jour
  1920. if ($this->maxH==0) $this->maxY = max($this->maxY, $y+$h);
  1921. // si le saut de ligne rentre => on le prend en compte, sinon nouvelle page
  1922. if ($y+$h<$this->pdf->h - $this->pdf->bMargin) $this->setNewLine($h, $curr);
  1923. else $this->setNewPage('', null, $curr);
  1924. $this->maxH = 0;
  1925. return true;
  1926. }
  1927. /**
  1928. * balise : HR
  1929. * mode : OUVERTURE
  1930. *
  1931. * @param array param�tres de l'�l�ment de parsing
  1932. * @return null
  1933. */
  1934. function o_HR($param)
  1935. {
  1936. if ($this->forOneLine) return false;
  1937. $old_align = $this->style->value['text-align'];
  1938. $this->style->value['text-align'] = 'left';
  1939. if ($this->maxH) $this->o_BR($param);
  1940. $f_size = $this->style->value['font-size'];
  1941. $this->style->value['font-size']=$f_size*0.5; $this->o_BR($param);
  1942. $this->style->value['font-size']=0;
  1943. $param['style']['width'] = '100%';
  1944. $this->style->save();
  1945. $this->style->value['height']=$this->style->ConvertToMM('1mm');
  1946. $this->style->analyse('hr', $param);
  1947. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1948. $this->style->FontSet();
  1949. $h = $this->style->value['height'];
  1950. if ($h) $h-= $this->style->value['border']['t']['width']+$this->style->value['border']['b']['width'];
  1951. if ($h<=0) $h = $this->style->value['border']['t']['width']+$this->style->value['border']['b']['width'];
  1952. $this->Rectangle($this->pdf->x, $this->pdf->y, $this->style->value['width'], $h, $this->style->value['border'], 0, 0, $this->style->value['background']);
  1953. $this->maxH = $h;
  1954. $this->style->load();
  1955. $this->style->FontSet();
  1956. $this->o_BR($param);
  1957. $this->style->value['font-size']=$f_size*0.5; $this->o_BR($param);
  1958. $this->style->value['font-size']=$f_size;
  1959. $this->style->value['text-align'] = $old_align;
  1960. $this->setNewPositionForNewLine();
  1961. return true;
  1962. }
  1963. /**
  1964. * balise : B
  1965. * mode : OUVERTURE
  1966. *
  1967. * @param array param�tres de l'�l�ment de parsing
  1968. * @return null
  1969. */
  1970. function o_B($param, $other = 'b')
  1971. {
  1972. $this->style->save();
  1973. $this->style->value['font-bold'] = true;
  1974. $this->style->analyse($other, $param);
  1975. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  1976. $this->style->FontSet();
  1977. return true;
  1978. }
  1979. function o_STRONG($param) { return $this->o_B($param, 'strong'); }
  1980. /**
  1981. * balise : B
  1982. * mode : FERMETURE
  1983. *
  1984. * @param array param�tres de l'�l�ment de parsing
  1985. * @return null
  1986. */
  1987. function c_B($param)
  1988. {
  1989. $this->style->load();
  1990. $this->style->FontSet();
  1991. return true;
  1992. }
  1993. function c_STRONG($param) { return $this->c_B($param); }
  1994. /**
  1995. * balise : I
  1996. * mode : OUVERTURE
  1997. *
  1998. * @param array param�tres de l'�l�ment de parsing
  1999. * @return null
  2000. */
  2001. function o_I($param, $other = 'i')
  2002. {
  2003. $this->style->save();
  2004. $this->style->value['font-italic'] = true;
  2005. $this->style->analyse($other, $param);
  2006. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2007. $this->style->FontSet();
  2008. return true;
  2009. }
  2010. function o_ADDRESS($param) { return $this->o_I($param, 'address'); }
  2011. function o_CITE($param) { return $this->o_I($param, 'cite'); }
  2012. function o_EM($param) { return $this->o_I($param, 'em'); }
  2013. function o_SAMP($param) { return $this->o_I($param, 'samp'); }
  2014. /**
  2015. * balise : I
  2016. * mode : FERMETURE
  2017. *
  2018. * @param array param�tres de l'�l�ment de parsing
  2019. * @return null
  2020. */
  2021. function c_I($param)
  2022. {
  2023. $this->style->load();
  2024. $this->style->FontSet();
  2025. return true;
  2026. }
  2027. function c_ADDRESS($param) { return $this->c_I($param); }
  2028. function c_CITE($param) { return $this->c_I($param); }
  2029. function c_EM($param) { return $this->c_I($param); }
  2030. function c_SAMP($param) { return $this->c_I($param); }
  2031. /**
  2032. * balise : S
  2033. * mode : OUVERTURE
  2034. *
  2035. * @param array param�tres de l'�l�ment de parsing
  2036. * @return null
  2037. */
  2038. function o_S($param)
  2039. {
  2040. $this->style->save();
  2041. $this->style->value['font-linethrough'] = true;
  2042. $this->style->analyse('s', $param);
  2043. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2044. $this->style->FontSet();
  2045. return true;
  2046. }
  2047. /**
  2048. * balise : S
  2049. * mode : FERMETURE
  2050. *
  2051. * @param array param�tres de l'�l�ment de parsing
  2052. * @return null
  2053. */
  2054. function c_S($param)
  2055. {
  2056. $this->style->load();
  2057. $this->style->FontSet();
  2058. return true;
  2059. }
  2060. /**
  2061. * balise : U
  2062. * mode : OUVERTURE
  2063. *
  2064. * @param array param�tres de l'�l�ment de parsing
  2065. * @return null
  2066. */
  2067. function o_U($param)
  2068. {
  2069. $this->style->save();
  2070. $this->style->value['font-underline'] = true;
  2071. $this->style->analyse('u', $param);
  2072. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2073. $this->style->FontSet();
  2074. return true;
  2075. }
  2076. /**
  2077. * balise : U
  2078. * mode : FERMETURE
  2079. *
  2080. * @param array param�tres de l'�l�ment de parsing
  2081. * @return null
  2082. */
  2083. function c_U($param)
  2084. {
  2085. $this->style->load();
  2086. $this->style->FontSet();
  2087. return true;
  2088. }
  2089. /**
  2090. * balise : A
  2091. * mode : OUVERTURE
  2092. *
  2093. * @param array param�tres de l'�l�ment de parsing
  2094. * @return null
  2095. */
  2096. function o_A($param)
  2097. {
  2098. $this->inLink = str_replace('&amp;', '&', isset($param['href']) ? $param['href'] : '');
  2099. if (isset($param['name']))
  2100. {
  2101. $nom = $param['name'];
  2102. if (!isset($this->lstAncre[$nom])) $this->lstAncre[$nom] = array($this->pdf->AddLink(), false);
  2103. if (!$this->lstAncre[$nom][1])
  2104. {
  2105. $this->lstAncre[$nom][1] = true;
  2106. $this->pdf->SetLink($this->lstAncre[$nom][0], -1, -1);
  2107. }
  2108. }
  2109. if (preg_match('/^#([^#]+)$/isU', $this->inLink, $match))
  2110. {
  2111. $nom = $match[1];
  2112. if (!isset($this->lstAncre[$nom])) $this->lstAncre[$nom] = array($this->pdf->AddLink(), false);
  2113. $this->inLink = $this->lstAncre[$nom][0];
  2114. }
  2115. $this->style->save();
  2116. $this->style->value['font-underline'] = true;
  2117. $this->style->value['color'] = array(20, 20, 250);
  2118. $this->style->analyse('a', $param);
  2119. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2120. $this->style->FontSet();
  2121. return true;
  2122. }
  2123. /**
  2124. * balise : A
  2125. * mode : FERMETURE
  2126. *
  2127. * @param array param�tres de l'�l�ment de parsing
  2128. * @return null
  2129. */
  2130. function c_A($param)
  2131. {
  2132. $this->inLink = '';
  2133. $this->style->load();
  2134. $this->style->FontSet();
  2135. return true;
  2136. }
  2137. /**
  2138. * balise : H1
  2139. * mode : OUVERTURE
  2140. *
  2141. * @param array param�tres de l'�l�ment de parsing
  2142. * @return null
  2143. */
  2144. function o_H1($param)
  2145. {
  2146. if ($this->forOneLine) return false;
  2147. $this->o_BR(array());
  2148. $this->style->save();
  2149. $this->style->value['font-bold'] = true;
  2150. $this->style->value['font-size'] = $this->style->ConvertToMM('28px');
  2151. $this->style->analyse('h1', $param);
  2152. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2153. $this->style->FontSet();
  2154. $this->setNewPositionForNewLine();
  2155. return true;
  2156. }
  2157. /**
  2158. * balise : H1
  2159. * mode : FERMETURE
  2160. *
  2161. * @param array param�tres de l'�l�ment de parsing
  2162. * @return null
  2163. */
  2164. function c_H1($param)
  2165. {
  2166. if ($this->forOneLine) return false;
  2167. $this->o_BR(array());
  2168. $this->style->load();
  2169. $this->style->FontSet();
  2170. $this->o_BR(array());
  2171. return true;
  2172. }
  2173. /**
  2174. * balise : H2
  2175. * mode : OUVERTURE
  2176. *
  2177. * @param array param�tres de l'�l�ment de parsing
  2178. * @return null
  2179. */
  2180. function o_H2($param)
  2181. {
  2182. if ($this->forOneLine) return false;
  2183. $this->o_BR(array());
  2184. $this->style->save();
  2185. $this->style->value['font-bold'] = true;
  2186. $this->style->value['font-size'] = $this->style->ConvertToMM('24px');
  2187. $this->style->analyse('h2', $param);
  2188. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2189. $this->style->FontSet();
  2190. $this->setNewPositionForNewLine();
  2191. return true;
  2192. }
  2193. /**
  2194. * balise : H2
  2195. * mode : FERMETURE
  2196. *
  2197. * @param array param�tres de l'�l�ment de parsing
  2198. * @return null
  2199. */
  2200. function c_H2($param)
  2201. {
  2202. if ($this->forOneLine) return false;
  2203. $this->o_BR(array());
  2204. $this->style->load();
  2205. $this->style->FontSet();
  2206. $this->o_BR(array());
  2207. return true;
  2208. }
  2209. /**
  2210. * balise : H3
  2211. * mode : OUVERTURE
  2212. *
  2213. * @param array param�tres de l'�l�ment de parsing
  2214. * @return null
  2215. */
  2216. function o_H3($param)
  2217. {
  2218. if ($this->forOneLine) return false;
  2219. $this->o_BR(array());
  2220. $this->style->save();
  2221. $this->style->value['font-bold'] = true;
  2222. $this->style->value['font-size'] = $this->style->ConvertToMM('20px');
  2223. $this->style->analyse('h3', $param);
  2224. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2225. $this->style->FontSet();
  2226. $this->setNewPositionForNewLine();
  2227. return true;
  2228. }
  2229. /**
  2230. * balise : H3
  2231. * mode : FERMETURE
  2232. *
  2233. * @param array param�tres de l'�l�ment de parsing
  2234. * @return null
  2235. */
  2236. function c_H3($param)
  2237. {
  2238. if ($this->forOneLine) return false;
  2239. $this->o_BR(array());
  2240. $this->style->load();
  2241. $this->style->FontSet();
  2242. $this->o_BR(array());
  2243. return true;
  2244. }
  2245. /**
  2246. * balise : H4
  2247. * mode : OUVERTURE
  2248. *
  2249. * @param array param�tres de l'�l�ment de parsing
  2250. * @return null
  2251. */
  2252. function o_H4($param)
  2253. {
  2254. if ($this->forOneLine) return false;
  2255. $this->o_BR(array());
  2256. $this->style->save();
  2257. $this->style->value['font-bold'] = true;
  2258. $this->style->value['font-size'] = $this->style->ConvertToMM('16px');
  2259. $this->style->analyse('h4', $param);
  2260. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2261. $this->style->FontSet();
  2262. $this->setNewPositionForNewLine();
  2263. return true;
  2264. }
  2265. /**
  2266. * balise : H4
  2267. * mode : FERMETURE
  2268. *
  2269. * @param array param�tres de l'�l�ment de parsing
  2270. * @return null
  2271. */
  2272. function c_H4($param)
  2273. {
  2274. if ($this->forOneLine) return false;
  2275. $this->o_BR(array());
  2276. $this->style->load();
  2277. $this->style->FontSet();
  2278. $this->o_BR(array());
  2279. return true;
  2280. }
  2281. /**
  2282. * balise : H5
  2283. * mode : OUVERTURE
  2284. *
  2285. * @param array param�tres de l'�l�ment de parsing
  2286. * @return null
  2287. */
  2288. function o_H5($param)
  2289. {
  2290. if ($this->forOneLine) return false;
  2291. $this->o_BR(array());
  2292. $this->style->save();
  2293. $this->style->value['font-bold'] = true;
  2294. $this->style->value['font-size'] = $this->style->ConvertToMM('12px');
  2295. $this->style->analyse('h5', $param);
  2296. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2297. $this->style->FontSet();
  2298. $this->setNewPositionForNewLine();
  2299. return true;
  2300. }
  2301. /**
  2302. * balise : H5
  2303. * mode : FERMETURE
  2304. *
  2305. * @param array param�tres de l'�l�ment de parsing
  2306. * @return null
  2307. */
  2308. function c_H5($param)
  2309. {
  2310. if ($this->forOneLine) return false;
  2311. $this->o_BR(array());
  2312. $this->style->load();
  2313. $this->style->FontSet();
  2314. $this->o_BR(array());
  2315. return true;
  2316. }
  2317. /**
  2318. * balise : H6
  2319. * mode : OUVERTURE
  2320. *
  2321. * @param array param�tres de l'�l�ment de parsing
  2322. * @return null
  2323. */
  2324. function o_H6($param)
  2325. {
  2326. if ($this->forOneLine) return false;
  2327. $this->o_BR(array());
  2328. $this->style->save();
  2329. $this->style->value['font-bold'] = true;
  2330. $this->style->value['font-size'] = $this->style->ConvertToMM('9px');
  2331. $this->style->analyse('h6', $param);
  2332. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2333. $this->style->FontSet();
  2334. $this->setNewPositionForNewLine();
  2335. return true;
  2336. }
  2337. /**
  2338. * balise : H6
  2339. * mode : FERMETURE
  2340. *
  2341. * @param array param�tres de l'�l�ment de parsing
  2342. * @return null
  2343. */
  2344. function c_H6($param)
  2345. {
  2346. if ($this->forOneLine) return false;
  2347. $this->o_BR(array());
  2348. $this->style->load();
  2349. $this->style->FontSet();
  2350. $this->o_BR(array());
  2351. return true;
  2352. }
  2353. /**
  2354. * balise : SPAN
  2355. * mode : OUVERTURE
  2356. *
  2357. * @param array param�tres de l'�l�ment de parsing
  2358. * @return null
  2359. */
  2360. function o_SPAN($param, $other = 'span')
  2361. {
  2362. $this->style->save();
  2363. $this->style->analyse($other, $param);
  2364. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2365. $this->style->FontSet();
  2366. return true;
  2367. }
  2368. function o_FONT($param) { return $this->o_SPAN($param, 'font'); }
  2369. /**
  2370. * balise : SPAN
  2371. * mode : FERMETURE
  2372. *
  2373. * @param array param�tres de l'�l�ment de parsing
  2374. * @return null
  2375. */
  2376. function c_SPAN($param)
  2377. {
  2378. $this->style->restorePosition($this->pdf->x, $this->pdf->y);
  2379. $this->style->load();
  2380. $this->style->FontSet();
  2381. return true;
  2382. }
  2383. function c_FONT($param) { return $this->c_SPAN($param); }
  2384. /**
  2385. * balise : P
  2386. * mode : OUVERTURE
  2387. *
  2388. * @param array param�tres de l'�l�ment de parsing
  2389. * @return null
  2390. */
  2391. function o_P($param)
  2392. {
  2393. if ($this->forOneLine) return false;
  2394. if (!in_array($this->previousCall, array('c_P', 'c_UL')))
  2395. {
  2396. if ($this->maxH) $this->o_BR(array());
  2397. $this->o_BR(array());
  2398. }
  2399. $this->style->save();
  2400. $this->style->analyse('p', $param);
  2401. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2402. $this->style->FontSet();
  2403. if ($this->style->value['text-indent']>0) $this->pdf->x+= $this->style->value['text-indent'];
  2404. return true;
  2405. }
  2406. /**
  2407. * balise : P
  2408. * mode : FERMETURE
  2409. *
  2410. * @param array param�tres de l'�l�ment de parsing
  2411. * @return null
  2412. */
  2413. function c_P($param)
  2414. {
  2415. if ($this->forOneLine) return false;
  2416. if ($this->maxH) $this->o_BR(array());
  2417. $this->o_BR(array());
  2418. $this->style->load();
  2419. $this->style->FontSet();
  2420. return true;
  2421. }
  2422. /**
  2423. * balise : PRE
  2424. * mode : OUVERTURE
  2425. *
  2426. * @param array param�tres de l'�l�ment de parsing
  2427. * @return null
  2428. */
  2429. function o_PRE($param, $other = 'pre')
  2430. {
  2431. if ($other=='pre' && $this->maxH) $this->o_BR(array());
  2432. $this->style->save();
  2433. $this->style->value['font-family'] = 'courier';
  2434. $this->style->analyse($other, $param);
  2435. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2436. $this->style->FontSet();
  2437. if ($other=='pre') return $this->o_DIV($param, $other);
  2438. return true;
  2439. }
  2440. function o_CODE($param) { return $this->o_PRE($param, 'code'); }
  2441. /**
  2442. * balise : PRE
  2443. * mode : FERMETURE
  2444. *
  2445. * @param array param�tres de l'�l�ment de parsing
  2446. * @return null
  2447. */
  2448. function c_PRE($param, $other = 'pre')
  2449. {
  2450. if ($other=='pre')
  2451. {
  2452. if ($this->forOneLine) return false;
  2453. $this->c_DIV($param);
  2454. $this->o_BR(array());
  2455. }
  2456. $this->style->load();
  2457. $this->style->FontSet();
  2458. return true;
  2459. }
  2460. function c_CODE($param) { return $this->c_PRE($param, 'code'); }
  2461. /**
  2462. * balise : BIG
  2463. * mode : OUVERTURE
  2464. *
  2465. * @param array param�tres de l'�l�ment de parsing
  2466. * @return null
  2467. */
  2468. function o_BIG($param)
  2469. {
  2470. $this->style->save();
  2471. $this->style->value['mini-decal']-= $this->style->value['mini-size']*0.2;
  2472. $this->style->value['mini-size'] *= 1.2;
  2473. $this->style->analyse('big', $param);
  2474. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2475. $this->style->FontSet();
  2476. return true;
  2477. }
  2478. /**
  2479. * balise : BIG
  2480. * mode : FERMETURE
  2481. *
  2482. * @param array param�tres de l'�l�ment de parsing
  2483. * @return null
  2484. */
  2485. function c_BIG($param)
  2486. {
  2487. $this->style->load();
  2488. $this->style->FontSet();
  2489. return true;
  2490. }
  2491. /**
  2492. * balise : SMALL
  2493. * mode : OUVERTURE
  2494. *
  2495. * @param array param�tres de l'�l�ment de parsing
  2496. * @return null
  2497. */
  2498. function o_SMALL($param)
  2499. {
  2500. $this->style->save();
  2501. $this->style->value['mini-decal']+= $this->style->value['mini-size']*0.18;
  2502. $this->style->value['mini-size'] *= 0.82;
  2503. $this->style->analyse('small', $param);
  2504. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2505. $this->style->FontSet();
  2506. return true;
  2507. }
  2508. /**
  2509. * balise : SMALL
  2510. * mode : FERMETURE
  2511. *
  2512. * @param array param�tres de l'�l�ment de parsing
  2513. * @return null
  2514. */
  2515. function c_SMALL($param)
  2516. {
  2517. $this->style->load();
  2518. $this->style->FontSet();
  2519. return true;
  2520. }
  2521. /**
  2522. * balise : SUP
  2523. * mode : OUVERTURE
  2524. *
  2525. * @param array param�tres de l'�l�ment de parsing
  2526. * @return null
  2527. */
  2528. function o_SUP($param)
  2529. {
  2530. $this->style->save();
  2531. $this->style->value['mini-decal']-= $this->style->value['mini-size']*0.25;
  2532. $this->style->value['mini-size'] *= 0.75;
  2533. $this->style->analyse('sup', $param);
  2534. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2535. $this->style->FontSet();
  2536. return true;
  2537. }
  2538. /**
  2539. * balise : SUP
  2540. * mode : FERMETURE
  2541. *
  2542. * @param array param�tres de l'�l�ment de parsing
  2543. * @return null
  2544. */
  2545. function c_SUP($param)
  2546. {
  2547. $this->style->load();
  2548. $this->style->FontSet();
  2549. return true;
  2550. }
  2551. /**
  2552. * balise : SUB
  2553. * mode : OUVERTURE
  2554. *
  2555. * @param array param�tres de l'�l�ment de parsing
  2556. * @return null
  2557. */
  2558. function o_SUB($param)
  2559. {
  2560. $this->style->save();
  2561. $this->style->value['mini-decal']+= $this->style->value['mini-size']*0.25;
  2562. $this->style->value['mini-size'] *= 0.75;
  2563. $this->style->analyse('sub', $param);
  2564. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2565. $this->style->FontSet();
  2566. $this->inSub = 1;
  2567. return true;
  2568. }
  2569. /**
  2570. * balise : SUB
  2571. * mode : FERMETURE
  2572. *
  2573. * @param array param�tres de l'�l�ment de parsing
  2574. * @return null
  2575. */
  2576. function c_SUB($param)
  2577. {
  2578. $this->style->load();
  2579. $this->style->FontSet();
  2580. return true;
  2581. }
  2582. /**
  2583. * balise : UL
  2584. * mode : OUVERTURE
  2585. *
  2586. * @param array param�tres de l'�l�ment de parsing
  2587. * @return null
  2588. */
  2589. function o_UL($param, $other = 'ul')
  2590. {
  2591. if ($this->forOneLine) return false;
  2592. if (!in_array($this->previousCall, array('c_P', 'c_UL')))
  2593. {
  2594. if ($this->maxH) $this->o_BR(array());
  2595. if (!count($this->defLIST)) $this->o_BR(array());
  2596. }
  2597. if (!isset($param['style']['width'])) $param['allwidth'] = true;
  2598. $param['cellspacing'] = 0;
  2599. // une liste est trait�e comme un tableau
  2600. $this->o_TABLE($param, $other);
  2601. // ajouter un niveau de liste
  2602. $this->listeAddLevel($other, $this->style->value['list-style-type'], $this->style->value['list-style-image']);
  2603. return true;
  2604. }
  2605. function o_OL($param) { return $this->o_UL($param, 'ol'); }
  2606. /**
  2607. * balise : UL
  2608. * mode : FERMETURE
  2609. *
  2610. * @param array param�tres de l'�l�ment de parsing
  2611. * @return null
  2612. */
  2613. function c_UL($param)
  2614. {
  2615. if ($this->forOneLine) return false;
  2616. // fin du tableau
  2617. $this->c_TABLE($param);
  2618. // enlever un niveau de liste
  2619. $this->listeDelLevel();
  2620. if (!$this->sub_part)
  2621. {
  2622. if (!count($this->defLIST)) $this->o_BR(array());
  2623. }
  2624. return true;
  2625. }
  2626. function c_OL($param) { return $this->c_UL($param); }
  2627. /**
  2628. * balise : LI
  2629. * mode : OUVERTURE
  2630. *
  2631. * @param array param�tres de l'�l�ment de parsing
  2632. * @return null
  2633. */
  2634. function o_LI($param)
  2635. {
  2636. if ($this->forOneLine) return false;
  2637. // ajouter une puce au niveau actuel
  2638. $this->listeAddLi();
  2639. if (!isset($param['style']['width'])) $param['style']['width'] = '100%';
  2640. // preparation du style de la puce
  2641. $paramPUCE = $param;
  2642. $inf = $this->listeGetLi();
  2643. if ($inf[0])
  2644. {
  2645. $paramPUCE['style']['font-family'] = $inf[0];
  2646. $paramPUCE['style']['text-align'] = 'li_right';
  2647. $paramPUCE['style']['vertical-align'] = 'top';
  2648. $paramPUCE['style']['width'] = $this->listeGetWidth();
  2649. $paramPUCE['style']['padding-right'] = $this->listeGetPadding();
  2650. $paramPUCE['txt'] = $inf[2];
  2651. }
  2652. else
  2653. {
  2654. $paramPUCE['style']['text-align'] = 'li_right';
  2655. $paramPUCE['style']['vertical-align'] = 'top';
  2656. $paramPUCE['style']['width'] = $this->listeGetWidth();
  2657. $paramPUCE['style']['padding-right'] = $this->listeGetPadding();
  2658. $paramPUCE['src'] = $inf[2];
  2659. $paramPUCE['sub_li'] = true;
  2660. }
  2661. // nouvelle ligne
  2662. $this->o_TR($param, 'li');
  2663. $this->style->save();
  2664. if ($inf[1])
  2665. {
  2666. $this->style->value['mini-decal']+= $this->style->value['mini-size']*0.25;
  2667. $this->style->value['mini-size'] *= 0.75;
  2668. }
  2669. // si on est dans un sub_html => preparation, sinon affichage classique
  2670. if ($this->sub_part)
  2671. {
  2672. // TD pour la puce
  2673. $tmp_pos = $this->temp_pos;
  2674. $tmp_lst1 = $this->parsing->code[$tmp_pos+1];
  2675. $tmp_lst2 = $this->parsing->code[$tmp_pos+2];
  2676. $this->parsing->code[$tmp_pos+1] = array();
  2677. $this->parsing->code[$tmp_pos+1]['name'] = (isset($paramPUCE['src'])) ? 'img' : 'write';
  2678. $this->parsing->code[$tmp_pos+1]['param'] = $paramPUCE; unset($this->parsing->code[$tmp_pos+1]['param']['style']['width']);
  2679. $this->parsing->code[$tmp_pos+1]['close'] = 0;
  2680. $this->parsing->code[$tmp_pos+2] = array();
  2681. $this->parsing->code[$tmp_pos+2]['name'] = 'li';
  2682. $this->parsing->code[$tmp_pos+2]['param'] = $paramPUCE;
  2683. $this->parsing->code[$tmp_pos+2]['close'] = 1;
  2684. $this->o_TD($paramPUCE, 'li_sub');
  2685. $this->c_TD($param);
  2686. $this->temp_pos = $tmp_pos;
  2687. $this->parsing->code[$tmp_pos+1] = $tmp_lst1;
  2688. $this->parsing->code[$tmp_pos+2] = $tmp_lst2;
  2689. }
  2690. else
  2691. {
  2692. // TD pour la puce
  2693. $this->o_TD($paramPUCE, 'li_sub');
  2694. unset($paramPUCE['style']['width']);
  2695. if (isset($paramPUCE['src'])) $this->o_IMG($paramPUCE);
  2696. else $this->o_WRITE($paramPUCE);
  2697. $this->c_TD($paramPUCE);
  2698. }
  2699. $this->style->load();
  2700. // td pour le contenu
  2701. $this->o_TD($param, 'li');
  2702. return true;
  2703. }
  2704. /**
  2705. * balise : LI
  2706. * mode : FERMETURE
  2707. *
  2708. * @param array param�tres de l'�l�ment de parsing
  2709. * @return null
  2710. */
  2711. function c_LI($param)
  2712. {
  2713. if ($this->forOneLine) return false;
  2714. // fin du contenu
  2715. $this->c_TD($param, 'li');
  2716. // fin de la ligne
  2717. $this->c_TR($param, 'li');
  2718. return true;
  2719. }
  2720. /**
  2721. * balise : TBODY
  2722. * mode : OUVERTURE
  2723. *
  2724. * @param array param�tres de l'�l�ment de parsing
  2725. * @return null
  2726. */
  2727. function o_TBODY($param)
  2728. {
  2729. if ($this->forOneLine) return false;
  2730. $this->style->save();
  2731. $this->style->analyse('tbody', $param);
  2732. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2733. $this->style->FontSet();
  2734. return true;
  2735. }
  2736. /**
  2737. * balise : TBODY
  2738. * mode : FERMETURE
  2739. *
  2740. * @param array param�tres de l'�l�ment de parsing
  2741. * @return null
  2742. */
  2743. function c_TBODY($param)
  2744. {
  2745. if ($this->forOneLine) return false;
  2746. $this->style->load();
  2747. $this->style->FontSet();
  2748. return true;
  2749. }
  2750. /**
  2751. * balise : THEAD
  2752. * mode : OUVERTURE
  2753. *
  2754. * @param array param�tres de l'�l�ment de parsing
  2755. * @return null
  2756. */
  2757. function o_THEAD($param)
  2758. {
  2759. if ($this->forOneLine) return false;
  2760. global $HTML2PDF_TABLEAU;
  2761. $this->style->save();
  2762. $this->style->analyse('thead', $param);
  2763. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2764. $this->style->FontSet();
  2765. // si on est en mode sub_html : sauvegarde du num�ro du TR
  2766. if ($this->sub_part)
  2767. {
  2768. $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0] = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
  2769. $HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array();
  2770. for($pos=$this->temp_pos; $pos<count($this->parsing->code); $pos++)
  2771. {
  2772. $todo = $this->parsing->code[$pos];
  2773. if (strtolower($todo['name'])=='thead') $todo['name'] = 'thead_sub';
  2774. $HTML2PDF_TABLEAU[$param['num']]['thead']['code'][] = $todo;
  2775. if (strtolower($todo['name'])=='thead_sub' && $todo['close']) break;
  2776. }
  2777. }
  2778. else
  2779. {
  2780. $res = $this->parsing->getLevel($this->parse_pos);
  2781. $this->parse_pos = $res[0]-1;
  2782. $HTML2PDF_TABLEAU[$param['num']]['tr_curr']+= count($HTML2PDF_TABLEAU[$param['num']]['thead']['tr']);
  2783. }
  2784. return true;
  2785. }
  2786. /**
  2787. * balise : THEAD
  2788. * mode : FERMETURE
  2789. *
  2790. * @param array param�tres de l'�l�ment de parsing
  2791. * @return null
  2792. */
  2793. function c_THEAD($param)
  2794. {
  2795. if ($this->forOneLine) return false;
  2796. $this->style->load();
  2797. $this->style->FontSet();
  2798. // si on est en mode sub_html : sauvegarde du num�ro du TR
  2799. if ($this->sub_part)
  2800. {
  2801. global $HTML2PDF_TABLEAU;
  2802. $min = $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
  2803. $max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
  2804. $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = range($min, $max);
  2805. }
  2806. return true;
  2807. }
  2808. /**
  2809. * balise : TFOOT
  2810. * mode : OUVERTURE
  2811. *
  2812. * @param array param�tres de l'�l�ment de parsing
  2813. * @return null
  2814. */
  2815. function o_TFOOT($param)
  2816. {
  2817. if ($this->forOneLine) return false;
  2818. global $HTML2PDF_TABLEAU;
  2819. $this->style->save();
  2820. $this->style->analyse('tfoot', $param);
  2821. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2822. $this->style->FontSet();
  2823. // si on est en mode sub_html : sauvegarde du num�ro du TR
  2824. if ($this->sub_part)
  2825. {
  2826. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0] = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
  2827. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array();
  2828. for($pos=$this->temp_pos; $pos<count($this->parsing->code); $pos++)
  2829. {
  2830. $todo = $this->parsing->code[$pos];
  2831. if (strtolower($todo['name'])=='tfoot') $todo['name'] = 'tfoot_sub';
  2832. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'][] = $todo;
  2833. if (strtolower($todo['name'])=='tfoot_sub' && $todo['close']) break;
  2834. }
  2835. }
  2836. else
  2837. {
  2838. $res = $this->parsing->getLevel($this->parse_pos+1);
  2839. $this->parse_pos = $res[0];
  2840. $HTML2PDF_TABLEAU[$param['num']]['tr_curr']+= count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr']);
  2841. }
  2842. return true;
  2843. }
  2844. /**
  2845. * balise : TFOOT
  2846. * mode : FERMETURE
  2847. *
  2848. * @param array param�tres de l'�l�ment de parsing
  2849. * @return null
  2850. */
  2851. function c_TFOOT($param)
  2852. {
  2853. if ($this->forOneLine) return false;
  2854. $this->style->load();
  2855. $this->style->FontSet();
  2856. // si on est en mode sub_html : sauvegarde du num�ro du TR
  2857. if ($this->sub_part)
  2858. {
  2859. global $HTML2PDF_TABLEAU;
  2860. $min = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
  2861. $max = $HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1;
  2862. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = range($min, $max);
  2863. }
  2864. return true;
  2865. }
  2866. /**
  2867. * balise : THEAD_SUB
  2868. * mode : OUVERTURE
  2869. *
  2870. * @param array param�tres de l'�l�ment de parsing
  2871. * @return null
  2872. */
  2873. function o_THEAD_SUB($param)
  2874. {
  2875. if ($this->forOneLine) return false;
  2876. $this->style->save();
  2877. $this->style->analyse('thead', $param);
  2878. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2879. $this->style->FontSet();
  2880. return true;
  2881. }
  2882. /**
  2883. * balise : THEAD_SUB
  2884. * mode : FERMETURE
  2885. *
  2886. * @param array param�tres de l'�l�ment de parsing
  2887. * @return null
  2888. */
  2889. function c_THEAD_SUB($param)
  2890. {
  2891. if ($this->forOneLine) return false;
  2892. $this->style->load();
  2893. $this->style->FontSet();
  2894. return true;
  2895. }
  2896. /**
  2897. * balise : TFOOT_SUB
  2898. * mode : OUVERTURE
  2899. *
  2900. * @param array param�tres de l'�l�ment de parsing
  2901. * @return null
  2902. */
  2903. function o_TFOOT_SUB($param)
  2904. {
  2905. if ($this->forOneLine) return false;
  2906. $this->style->save();
  2907. $this->style->analyse('tfoot', $param);
  2908. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2909. $this->style->FontSet();
  2910. return true;
  2911. }
  2912. /**
  2913. * balise : TFOOT_SUB
  2914. * mode : FERMETURE
  2915. *
  2916. * @param array param�tres de l'�l�ment de parsing
  2917. * @return null
  2918. */
  2919. function c_TFOOT_SUB($param)
  2920. {
  2921. if ($this->forOneLine) return false;
  2922. $this->style->load();
  2923. $this->style->FontSet();
  2924. return true;
  2925. }
  2926. /**
  2927. * balise : FORM
  2928. * mode : OUVERTURE
  2929. *
  2930. * @param array param�tres de l'�l�ment de parsing
  2931. * @return null
  2932. */
  2933. function o_FORM($param)
  2934. {
  2935. $this->style->save();
  2936. $this->style->analyse('form', $param);
  2937. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2938. $this->style->FontSet();
  2939. return true;
  2940. }
  2941. /**
  2942. * balise : FORM
  2943. * mode : FERMETURE
  2944. *
  2945. * @param array param�tres de l'�l�ment de parsing
  2946. * @return null
  2947. */
  2948. function c_FORM($param)
  2949. {
  2950. $this->style->load();
  2951. $this->style->FontSet();
  2952. return true;
  2953. }
  2954. /**
  2955. * balise : TABLE
  2956. * mode : OUVERTURE
  2957. *
  2958. * @param array param�tres de l'�l�ment de parsing
  2959. * @return null
  2960. */
  2961. function o_TABLE($param, $other = 'table')
  2962. {
  2963. if ($this->forOneLine) return false;
  2964. $this->maxH = 0;
  2965. // utilisation du tableau des param�tres des tables
  2966. global $HTML2PDF_TABLEAU;
  2967. $align_object = isset($param['align']) ? strtolower($param['align']) : 'left';
  2968. if (isset($param['align'])) unset($param['align']);
  2969. if (!in_array($align_object, array('left', 'center', 'right'))) $align_object = 'left';
  2970. // lecture et initialisation du style
  2971. $this->style->save();
  2972. $this->style->analyse($other, $param);
  2973. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  2974. $this->style->FontSet();
  2975. if ($this->style->value['margin-auto']) $align_object = 'center';
  2976. // est-on en collapse
  2977. $collapse = false;
  2978. if ($other=='table')
  2979. $collapse = isset($this->style->value['border']['collapse']) ? $this->style->value['border']['collapse'] : false;
  2980. // si oui il faut adapt� les borders
  2981. if ($collapse)
  2982. {
  2983. $param['style']['border'] = 'none';
  2984. $param['cellspacing'] = 0;
  2985. $none = $this->style->readBorder('none');
  2986. $this->style->value['border']['t'] = $none;
  2987. $this->style->value['border']['r'] = $none;
  2988. $this->style->value['border']['b'] = $none;
  2989. $this->style->value['border']['l'] = $none;
  2990. }
  2991. // si on est en mode sub_html : initialisation des dimensions et autres
  2992. if ($this->sub_part)
  2993. {
  2994. $HTML2PDF_TABLEAU[$param['num']] = array();
  2995. $HTML2PDF_TABLEAU[$param['num']]['cellpadding'] = $this->style->ConvertToMM(isset($param['cellpadding']) ? $param['cellpadding'] : '1px'); // cellpadding du tableau
  2996. $HTML2PDF_TABLEAU[$param['num']]['cellspacing'] = $this->style->ConvertToMM(isset($param['cellspacing']) ? $param['cellspacing'] : '2px'); // cellspacing du tableau
  2997. $HTML2PDF_TABLEAU[$param['num']]['cases'] = array(); // liste des propri�t�s des cases
  2998. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0; // colonne courante
  2999. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0; // ligne courante
  3000. $HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $this->pdf->getX(); // position courante X
  3001. $HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this->pdf->getY(); // position courante Y
  3002. $HTML2PDF_TABLEAU[$param['num']]['width'] = 0; // largeur globale
  3003. $HTML2PDF_TABLEAU[$param['num']]['height'] = 0; // hauteur globale
  3004. $HTML2PDF_TABLEAU[$param['num']]['align'] = $align_object;
  3005. $HTML2PDF_TABLEAU[$param['num']]['marge'] = array();
  3006. $HTML2PDF_TABLEAU[$param['num']]['marge']['t'] = $this->style->value['padding']['t']+$this->style->value['border']['t']['width']+$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
  3007. $HTML2PDF_TABLEAU[$param['num']]['marge']['r'] = $this->style->value['padding']['r']+$this->style->value['border']['r']['width']+$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
  3008. $HTML2PDF_TABLEAU[$param['num']]['marge']['b'] = $this->style->value['padding']['b']+$this->style->value['border']['b']['width']+$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
  3009. $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] = $this->style->value['padding']['l']+$this->style->value['border']['l']['width']+$HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5;
  3010. $HTML2PDF_TABLEAU[$param['num']]['page'] = 0; // nombre de pages
  3011. $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true; // nouvelle page pour le TR courant
  3012. $HTML2PDF_TABLEAU[$param['num']]['style_value'] = null; // style du tableau
  3013. $HTML2PDF_TABLEAU[$param['num']]['thead'] = array(); // infos sur le thead
  3014. $HTML2PDF_TABLEAU[$param['num']]['tfoot'] = array(); // infos sur le tfoot
  3015. $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'] = array(); // tr du thead
  3016. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'] = array(); // tr du tfoot
  3017. $HTML2PDF_TABLEAU[$param['num']]['thead']['height'] = 0; // hauteur du thead
  3018. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'] = 0; // hauteur du tfoot
  3019. $HTML2PDF_TABLEAU[$param['num']]['thead']['code'] = array(); // contenu HTML du thead
  3020. $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'] = array(); // contenu HTML du tfoot
  3021. $this->saveMargin($this->pdf->lMargin, $this->pdf->tMargin, $this->pdf->rMargin);
  3022. // adaptation de la largeur en fonction des marges du tableau
  3023. $this->style->value['width']-= $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['r'];
  3024. }
  3025. else
  3026. {
  3027. // on repart � la premiere page du tableau et � la premiere case
  3028. $HTML2PDF_TABLEAU[$param['num']]['page'] = 0;
  3029. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
  3030. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = 0;
  3031. $HTML2PDF_TABLEAU[$param['num']]['td_x'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['l']+$HTML2PDF_TABLEAU[$param['num']]['curr_x'];
  3032. $HTML2PDF_TABLEAU[$param['num']]['td_y'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['t']+$HTML2PDF_TABLEAU[$param['num']]['curr_y'];
  3033. // initialisation du style des bordures de la premiere partie de tableau
  3034. $this->Rectangle(
  3035. $HTML2PDF_TABLEAU[$param['num']]['curr_x'],
  3036. $HTML2PDF_TABLEAU[$param['num']]['curr_y'],
  3037. $HTML2PDF_TABLEAU[$param['num']]['width'],
  3038. isset($HTML2PDF_TABLEAU[$param['num']]['height'][0]) ? $HTML2PDF_TABLEAU[$param['num']]['height'][0] : null,
  3039. $this->style->value['border'],
  3040. $this->style->value['padding'],
  3041. 0,
  3042. $this->style->value['background']
  3043. );
  3044. $HTML2PDF_TABLEAU[$param['num']]['style_value'] = $this->style->value;
  3045. }
  3046. return true;
  3047. }
  3048. /**
  3049. * balise : TABLE
  3050. * mode : FERMETURE
  3051. *
  3052. * @param array param�tres de l'�l�ment de parsing
  3053. * @return null
  3054. */
  3055. function c_TABLE($param)
  3056. {
  3057. if ($this->forOneLine) return false;
  3058. $this->maxH = 0;
  3059. global $HTML2PDF_TABLEAU;
  3060. // restauration du style
  3061. $this->style->load();
  3062. $this->style->FontSet();
  3063. // si on est en mode sub_html : initialisation des dimensions et autres
  3064. if ($this->sub_part)
  3065. {
  3066. // ajustement de la taille des cases
  3067. $this->calculTailleCases($HTML2PDF_TABLEAU[$param['num']]['cases']);
  3068. // calcul de la hauteur du THEAD et du TFOOT
  3069. $lst = array('thead', 'tfoot');
  3070. foreach($lst as $mode)
  3071. {
  3072. $HTML2PDF_TABLEAU[$param['num']][$mode]['height'] = 0;
  3073. foreach($HTML2PDF_TABLEAU[$param['num']][$mode]['tr'] as $tr)
  3074. {
  3075. // hauteur de la ligne tr
  3076. $h = 0;
  3077. for($i=0; $i<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$tr]); $i++)
  3078. if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$tr][$i]['rowspan']==1)
  3079. $h = max($h, $HTML2PDF_TABLEAU[$param['num']]['cases'][$tr][$i]['h']);
  3080. $HTML2PDF_TABLEAU[$param['num']][$mode]['height']+= $h;
  3081. }
  3082. }
  3083. // calcul des dimensions du tableau - Largeur
  3084. $HTML2PDF_TABLEAU[$param['num']]['width'] = $HTML2PDF_TABLEAU[$param['num']]['marge']['l'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['r'];
  3085. if (isset($HTML2PDF_TABLEAU[$param['num']]['cases'][0]))
  3086. foreach($HTML2PDF_TABLEAU[$param['num']]['cases'][0] as $case)
  3087. $HTML2PDF_TABLEAU[$param['num']]['width']+= $case['w'];
  3088. // positionnement du tableau horizontalement;
  3089. $old = isset($this->style->table[count($this->style->table)-1]) ? $this->style->table[count($this->style->table)-1] : $this->style->value;
  3090. $parent_w = $old['width'] ? $old['width'] : $this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin;
  3091. $x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'];
  3092. $w = $HTML2PDF_TABLEAU[$param['num']]['width'];
  3093. if ($parent_w>$w)
  3094. {
  3095. if ($HTML2PDF_TABLEAU[$param['num']]['align']=='center')
  3096. $x = $x + ($parent_w-$w)*0.5;
  3097. else if ($HTML2PDF_TABLEAU[$param['num']]['align']=='right')
  3098. $x = $x + $parent_w-$w;
  3099. $HTML2PDF_TABLEAU[$param['num']]['curr_x'] = $x;
  3100. }
  3101. // calcul des dimensions du tableau - hauteur du tableau sur chaque page
  3102. $HTML2PDF_TABLEAU[$param['num']]['height'] = array();
  3103. $h0 = $HTML2PDF_TABLEAU[$param['num']]['marge']['t'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['b']; // minimum de hauteur � cause des marges
  3104. $h0+= $HTML2PDF_TABLEAU[$param['num']]['thead']['height'] + $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height']; // et du tfoot et thead
  3105. $max = $this->pdf->h - $this->pdf->bMargin; // max de hauteur par page
  3106. $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']; // position Y actuelle
  3107. $height = $h0;
  3108. // on va lire les hauteurs de chaque ligne, une � une, et voir si ca rentre sur la page.
  3109. for($k=0; $k<count($HTML2PDF_TABLEAU[$param['num']]['cases']); $k++)
  3110. {
  3111. // si c'est des lignes du thead ou du tfoot : on passe
  3112. if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'])) continue;
  3113. if (in_array($k, $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'])) continue;
  3114. // hauteur de la ligne $k
  3115. $th = 0;
  3116. $h = 0;
  3117. for($i=0; $i<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$k]); $i++)
  3118. {
  3119. $h = max($h, $HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['h']);
  3120. if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['rowspan']==1)
  3121. $th = max($th, $HTML2PDF_TABLEAU[$param['num']]['cases'][$k][$i]['h']);
  3122. }
  3123. // si la ligne ne rentre pas dans la page
  3124. // => la hauteur sur cette page est trouv�e, et on passe � la page d'apres
  3125. if ($y+$h+$height>$max)
  3126. {
  3127. if ($height==$h0) $height = null;
  3128. $HTML2PDF_TABLEAU[$param['num']]['height'][] = $height;
  3129. $height = $h0;
  3130. $y = $this->margeTop;
  3131. }
  3132. $height+= $th;
  3133. }
  3134. // rajout du reste de tableau (si il existe) � la derniere page
  3135. if ($height!=$h0 || $k==0) $HTML2PDF_TABLEAU[$param['num']]['height'][] = $height;
  3136. }
  3137. else
  3138. {
  3139. if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['code']))
  3140. {
  3141. $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
  3142. $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
  3143. $OLD_parse_pos = $this->parse_pos;
  3144. $OLD_parse_code = $this->parsing->code;
  3145. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
  3146. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
  3147. $this->parse_pos = 0;
  3148. $this->parsing->code = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
  3149. $this->MakeHTMLcode();
  3150. $this->parse_pos = $OLD_parse_pos;
  3151. $this->parsing->code = $OLD_parse_code;
  3152. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
  3153. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
  3154. }
  3155. // determination des coordonn�es de sortie du tableau
  3156. $x = $HTML2PDF_TABLEAU[$param['num']]['curr_x'] + $HTML2PDF_TABLEAU[$param['num']]['width'];
  3157. if (count($HTML2PDF_TABLEAU[$param['num']]['height'])>1)
  3158. $y = $this->margeTop+$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]['height'])-1];
  3159. else if (count($HTML2PDF_TABLEAU[$param['num']]['height'])==1)
  3160. $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y']+$HTML2PDF_TABLEAU[$param['num']]['height'][count($HTML2PDF_TABLEAU[$param['num']]['height'])-1];
  3161. else
  3162. $y = $HTML2PDF_TABLEAU[$param['num']]['curr_y'];
  3163. // restauration des marges
  3164. $this->loadMargin();
  3165. // position de sortie du tableau
  3166. $this->pdf->setX($x);
  3167. $this->pdf->setY($y);
  3168. $this->maxX = max($this->maxX, $x);
  3169. $this->maxY = max($this->maxY, $y);
  3170. }
  3171. return true;
  3172. }
  3173. /**
  3174. * balise : TR
  3175. * mode : OUVERTURE
  3176. *
  3177. * @param array param�tres de l'�l�ment de parsing
  3178. * @return null
  3179. */
  3180. function o_TR($param, $other = 'tr')
  3181. {
  3182. if ($this->forOneLine) return false;
  3183. $this->maxH = 0;
  3184. global $HTML2PDF_TABLEAU;
  3185. // analyse du style
  3186. $this->style->save();
  3187. $this->style->analyse($other, $param);
  3188. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3189. $this->style->FontSet();
  3190. // positionnement dans le tableau
  3191. $HTML2PDF_TABLEAU[$param['num']]['tr_curr']++;
  3192. $HTML2PDF_TABLEAU[$param['num']]['td_curr']= 0;
  3193. // si on est pas dans un sub_html
  3194. if (!$this->sub_part)
  3195. {
  3196. // Y courant apres la ligne
  3197. $ty=null;
  3198. for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++)
  3199. $ty = max($ty, $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['h']);
  3200. $hfoot = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['height'];
  3201. // si la ligne ne rentre pas dans la page => nouvelle page
  3202. if (!$this->isInTfoot && $HTML2PDF_TABLEAU[$param['num']]['td_y'] + $HTML2PDF_TABLEAU[$param['num']]['marge']['b'] + $ty +$hfoot> $this->pdf->h - $this->pdf->bMargin)
  3203. {
  3204. if (count($HTML2PDF_TABLEAU[$param['num']]['tfoot']['code']))
  3205. {
  3206. $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
  3207. $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
  3208. $OLD_parse_pos = $this->parse_pos;
  3209. $OLD_parse_code = $this->parsing->code;
  3210. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['tr'][0];
  3211. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
  3212. $this->parse_pos = 0;
  3213. $this->parsing->code = $HTML2PDF_TABLEAU[$param['num']]['tfoot']['code'];
  3214. $this->isInTfoot = true;
  3215. $this->MakeHTMLcode();
  3216. $this->isInTfoot = false;
  3217. $this->parse_pos = $OLD_parse_pos;
  3218. $this->parsing->code = $OLD_parse_code;
  3219. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
  3220. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
  3221. }
  3222. $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
  3223. $this->setNewPage();
  3224. $HTML2PDF_TABLEAU[$param['num']]['page']++;
  3225. $HTML2PDF_TABLEAU[$param['num']]['curr_y'] = $this->pdf->getY();
  3226. $HTML2PDF_TABLEAU[$param['num']]['td_y'] = $HTML2PDF_TABLEAU[$param['num']]['curr_y']+$HTML2PDF_TABLEAU[$param['num']]['marge']['t'];
  3227. // si la hauteur de cette partie a bien �t� calcul�e, on trace le cadre
  3228. if (isset($HTML2PDF_TABLEAU[$param['num']]['height'][$HTML2PDF_TABLEAU[$param['num']]['page']]))
  3229. {
  3230. $old = $this->style->value;
  3231. $this->style->value = $HTML2PDF_TABLEAU[$param['num']]['style_value'];
  3232. // initialisation du style des bordures de la premiere partie de tableau
  3233. $this->Rectangle(
  3234. $HTML2PDF_TABLEAU[$param['num']]['curr_x'],
  3235. $HTML2PDF_TABLEAU[$param['num']]['curr_y'],
  3236. $HTML2PDF_TABLEAU[$param['num']]['width'],
  3237. $HTML2PDF_TABLEAU[$param['num']]['height'][$HTML2PDF_TABLEAU[$param['num']]['page']],
  3238. $this->style->value['border'],
  3239. $this->style->value['padding'],
  3240. $HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5,
  3241. $this->style->value['background']
  3242. );
  3243. $this->style->value = $old;
  3244. }
  3245. }
  3246. if ($HTML2PDF_TABLEAU[$param['num']]['new_page'] && count($HTML2PDF_TABLEAU[$param['num']]['thead']['code']))
  3247. {
  3248. $HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
  3249. $tmp_tr = $HTML2PDF_TABLEAU[$param['num']]['tr_curr'];
  3250. $tmp_td = $HTML2PDF_TABLEAU[$param['num']]['td_curr'];
  3251. $OLD_parse_pos = $this->parse_pos;
  3252. $OLD_parse_code = $this->parsing->code;
  3253. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $HTML2PDF_TABLEAU[$param['num']]['thead']['tr'][0];
  3254. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = 0;
  3255. $this->parse_pos = 0;
  3256. $this->parsing->code = $HTML2PDF_TABLEAU[$param['num']]['thead']['code'];
  3257. $this->MakeHTMLcode();
  3258. $this->parse_pos = $OLD_parse_pos;
  3259. $this->parsing->code = $OLD_parse_code;
  3260. $HTML2PDF_TABLEAU[$param['num']]['tr_curr'] = $tmp_tr;
  3261. $HTML2PDF_TABLEAU[$param['num']]['td_curr'] = $tmp_td;
  3262. $HTML2PDF_TABLEAU[$param['num']]['new_page'] = true;
  3263. }
  3264. }
  3265. else
  3266. {
  3267. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1] = array();
  3268. }
  3269. return true;
  3270. }
  3271. /**
  3272. * balise : TR
  3273. * mode : FERMETURE
  3274. *
  3275. * @param array param�tres de l'�l�ment de parsing
  3276. * @return null
  3277. */
  3278. function c_TR($param)
  3279. {
  3280. if ($this->forOneLine) return false;
  3281. $this->maxH = 0;
  3282. global $HTML2PDF_TABLEAU;
  3283. // restauration du style
  3284. $this->style->load();
  3285. $this->style->FontSet();
  3286. // si on est pas dans un sub_html
  3287. if (!$this->sub_part)
  3288. {
  3289. // Y courant apres la ligne
  3290. $ty=null;
  3291. for($ii=0; $ii<count($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1]); $ii++)
  3292. if ($HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['rowspan']==1)
  3293. $ty = $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$ii]['h'];
  3294. // mise � jour des coordonn�es courantes
  3295. $HTML2PDF_TABLEAU[$param['num']]['td_x'] = $HTML2PDF_TABLEAU[$param['num']]['curr_x']+$HTML2PDF_TABLEAU[$param['num']]['marge']['l'];
  3296. $HTML2PDF_TABLEAU[$param['num']]['td_y']+= $ty;
  3297. $HTML2PDF_TABLEAU[$param['num']]['new_page'] = false;
  3298. }
  3299. return true;
  3300. }
  3301. /**
  3302. * balise : TD
  3303. * mode : OUVERTURE
  3304. *
  3305. * @param array param�tres de l'�l�ment de parsing
  3306. * @return null
  3307. */
  3308. function o_TD($param, $other = 'td')
  3309. {
  3310. if ($this->forOneLine) return false;
  3311. $this->maxH = 0;
  3312. global $HTML2PDF_TABLEAU;
  3313. $param['cellpadding'] = $HTML2PDF_TABLEAU[$param['num']]['cellpadding'].'mm';
  3314. $param['cellspacing'] = $HTML2PDF_TABLEAU[$param['num']]['cellspacing'].'mm';
  3315. if ($other=='li')
  3316. {
  3317. $special_li = true;
  3318. }
  3319. else
  3320. {
  3321. $special_li = false;
  3322. if ($other=='li_sub')
  3323. {
  3324. $param['style']['border'] = 'none';
  3325. $param['style']['background-color'] = 'transparent';
  3326. $param['style']['background-image'] = 'none';
  3327. $param['style']['background-position'] = '';
  3328. $param['style']['background-repeat'] = '';
  3329. $other = 'li';
  3330. }
  3331. }
  3332. // est-on en collapse
  3333. $collapse = false;
  3334. if (in_array($other, array('td', 'th')))
  3335. $collapse = isset($this->style->value['border']['collapse']) ? $this->style->value['border']['collapse'] : false;
  3336. // analyse du style
  3337. $this->style->save();
  3338. $this->style->analyse($other, $param);
  3339. if ($special_li)
  3340. {
  3341. $this->style->value['width']-= $this->style->ConvertToMM($this->listeGetWidth());
  3342. $this->style->value['width']-= $this->style->ConvertToMM($this->listeGetPadding());
  3343. }
  3344. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3345. $this->style->FontSet();
  3346. // si on est en collapse : modification du style
  3347. if ($collapse)
  3348. {
  3349. if (!$this->sub_part)
  3350. {
  3351. if ($HTML2PDF_TABLEAU[$param['num']]['tr_curr']>1 && !$HTML2PDF_TABLEAU[$param['num']]['new_page'])
  3352. $this->style->value['border']['t'] = $this->style->readBorder('none');
  3353. }
  3354. if ($HTML2PDF_TABLEAU[$param['num']]['td_curr']>0)
  3355. $this->style->value['border']['l'] = $this->style->readBorder('none');
  3356. }
  3357. $marge = array();
  3358. $marge['t'] = $this->style->value['padding']['t']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['t']['width'];
  3359. $marge['r'] = $this->style->value['padding']['r']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['r']['width'];
  3360. $marge['b'] = $this->style->value['padding']['b']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['b']['width'];
  3361. $marge['l'] = $this->style->value['padding']['l']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['l']['width'];
  3362. // si on est dans un sub_html
  3363. if ($this->sub_part)
  3364. {
  3365. // on se positionne dans le tableau
  3366. $HTML2PDF_TABLEAU[$param['num']]['td_curr']++;
  3367. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1] = array();
  3368. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'] = 0;
  3369. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['h'] = 0;
  3370. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['dw'] = 0;
  3371. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['colspan'] = isset($param['colspan']) ? $param['colspan'] : 1;
  3372. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['rowspan'] = isset($param['rowspan']) ? $param['rowspan'] : 1;
  3373. // on extrait tout ce qui est contenu dans le TD
  3374. $res = $this->parsing->getLevel($this->temp_pos);
  3375. // on en cr�� un sous HTML que l'on transforme en PDF
  3376. // pour analyse les dimensions
  3377. // et les r�cup�rer dans le tableau global.
  3378. $this->CreateSubHTML($this->sub_html);
  3379. $this->sub_html->writeHTML($res[1]);
  3380. $this->temp_pos = $res[0]-2;
  3381. }
  3382. else
  3383. {
  3384. // on se positionne dans le tableau
  3385. $HTML2PDF_TABLEAU[$param['num']]['td_curr']++;
  3386. $HTML2PDF_TABLEAU[$param['num']]['td_x']+= $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['dw'];
  3387. // initialisation du style des bordures de la premiere partie de tableau
  3388. $this->Rectangle(
  3389. $HTML2PDF_TABLEAU[$param['num']]['td_x'],
  3390. $HTML2PDF_TABLEAU[$param['num']]['td_y'],
  3391. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'],
  3392. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['h'],
  3393. $this->style->value['border'],
  3394. $this->style->value['padding'],
  3395. $HTML2PDF_TABLEAU[$param['num']]['cellspacing']*0.5,
  3396. $this->style->value['background']
  3397. );
  3398. $this->style->value['width'] = $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'] - $marge['l'] - $marge['r'];
  3399. // limitation des marges aux dimensions de la case
  3400. $mL = $HTML2PDF_TABLEAU[$param['num']]['td_x']+$marge['l'];
  3401. $mR = $this->pdf->w - $mL - $this->style->value['width'];
  3402. $this->saveMargin($mL, 0, $mR);
  3403. // positionnement en fonction
  3404. $h_corr = $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['h'];
  3405. $h_reel = $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['real_h'];
  3406. switch($this->style->value['vertical-align'])
  3407. {
  3408. case 'bottom':
  3409. $y_corr = $h_corr-$h_reel;
  3410. break;
  3411. case 'middle':
  3412. $y_corr = ($h_corr-$h_reel)*0.5;
  3413. break;
  3414. case 'top':
  3415. default:
  3416. $y_corr = 0;
  3417. break;
  3418. }
  3419. $this->pdf->setX($HTML2PDF_TABLEAU[$param['num']]['td_x']+$marge['l']);
  3420. $this->pdf->setY($HTML2PDF_TABLEAU[$param['num']]['td_y']+$marge['t']+$y_corr);
  3421. $this->setNewPositionForNewLine();
  3422. }
  3423. return true;
  3424. }
  3425. /**
  3426. * balise : TD
  3427. * mode : FERMETURE
  3428. *
  3429. * @param array param�tres de l'�l�ment de parsing
  3430. * @return null
  3431. */
  3432. function c_TD($param)
  3433. {
  3434. if ($this->forOneLine) return false;
  3435. $this->maxH = 0;
  3436. global $HTML2PDF_TABLEAU;
  3437. // r�cup�ration de la marge
  3438. $marge = array();
  3439. $marge['t'] = $this->style->value['padding']['t']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['t']['width'];
  3440. $marge['r'] = $this->style->value['padding']['r']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['r']['width'];
  3441. $marge['b'] = $this->style->value['padding']['b']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['b']['width'];
  3442. $marge['l'] = $this->style->value['padding']['l']+0.5*$HTML2PDF_TABLEAU[$param['num']]['cellspacing']+$this->style->value['border']['l']['width'];
  3443. $marge['t']+= 0.01;
  3444. $marge['r']+= 0.01;
  3445. $marge['b']+= 0.01;
  3446. $marge['l']+= 0.01;
  3447. // si on est dans un sub_html
  3448. if ($this->sub_part)
  3449. {
  3450. if ($this->testTDin1page && $this->sub_html->pdf->page>1) @HTML2PDF::makeError(7, __FILE__, __LINE__);
  3451. // dimentions de cette case
  3452. $w0 = $this->sub_html->maxX + $marge['l'] + $marge['r'];
  3453. $h0 = $this->sub_html->maxY + $marge['t'] + $marge['b'];
  3454. // dimensions impos�es par le style
  3455. $w2 = $this->style->value['width'] + $marge['l'] + $marge['r'];
  3456. $h2 = $this->style->value['height'] + $marge['t'] + $marge['b'];
  3457. // dimension finale de la case = max des 2 ci-dessus
  3458. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'] = max(array($w0, $w2));
  3459. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['h'] = max(array($h0, $h2));
  3460. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['real_w'] = $w0;
  3461. $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['real_h'] = $h0;
  3462. // suppresion du sous_html
  3463. $this->DestroySubHTML();
  3464. }
  3465. else
  3466. {
  3467. $this->loadMargin();
  3468. //positionnement
  3469. $HTML2PDF_TABLEAU[$param['num']]['td_x']+= $HTML2PDF_TABLEAU[$param['num']]['cases'][$HTML2PDF_TABLEAU[$param['num']]['tr_curr']-1][$HTML2PDF_TABLEAU[$param['num']]['td_curr']-1]['w'];
  3470. }
  3471. // restauration du style
  3472. $this->style->load();
  3473. $this->style->FontSet();
  3474. return true;
  3475. }
  3476. function calculTailleCases(&$cases)
  3477. {
  3478. // construction d'un tableau de correlation
  3479. $corr = array();
  3480. // on fait correspondre chaque case d'un tableau norm� aux cases r�elles, en prennant en compte les colspan et rowspan
  3481. $Yr=0;
  3482. for($y=0; $y<count($cases); $y++)
  3483. {
  3484. $Xr=0; while(isset($corr[$Yr][$Xr])) $Xr++;
  3485. for($x=0; $x<count($cases[$y]); $x++)
  3486. {
  3487. for($j=0; $j<$cases[$y][$x]['rowspan']; $j++)
  3488. {
  3489. for($i=0; $i<$cases[$y][$x]['colspan']; $i++)
  3490. {
  3491. $corr[$Yr+$j][$Xr+$i] = ($i+$j>0) ? '' : array($x, $y, $cases[$y][$x]['colspan'], $cases[$y][$x]['rowspan']);
  3492. }
  3493. }
  3494. $Xr+= $cases[$y][$x]['colspan'];
  3495. while(isset($corr[$Yr][$Xr])) $Xr++;
  3496. }
  3497. $Yr++;
  3498. }
  3499. if (!isset($corr[0])) return true;
  3500. // on d�termine, pour les cases sans colspan, la largeur maximale de chaque colone
  3501. $sw = array();
  3502. for($x=0; $x<count($corr[0]); $x++)
  3503. {
  3504. $m=0;
  3505. for($y=0; $y<count($corr); $y++)
  3506. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]==1)
  3507. $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w']);
  3508. $sw[$x] = $m;
  3509. }
  3510. // on v�rifie que cette taille est valide avec les colones en colspan
  3511. for($x=0; $x<count($corr[0]); $x++)
  3512. {
  3513. for($y=0; $y<count($corr); $y++)
  3514. {
  3515. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][2]>1)
  3516. {
  3517. // somme des colonnes correspondant au colspan
  3518. $s = 0; for($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
  3519. // si la somme est inf�rieure � la taille necessaire => r�gle de 3 pour adapter
  3520. if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'])
  3521. for($i=0; $i<$corr[$y][$x][2]; $i++)
  3522. $sw[$x+$i] = $sw[$x+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
  3523. }
  3524. }
  3525. }
  3526. // on applique les nouvelles largeurs
  3527. for($x=0; $x<count($corr[0]); $x++)
  3528. {
  3529. for($y=0; $y<count($corr); $y++)
  3530. {
  3531. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]))
  3532. {
  3533. if ($corr[$y][$x][2]==1)
  3534. {
  3535. $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $sw[$x];
  3536. }
  3537. else
  3538. {
  3539. // somme des colonnes correspondant au colspan
  3540. $s = 0; for($i=0; $i<$corr[$y][$x][2]; $i++) $s+= $sw[$x+$i];
  3541. $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'] = $s;
  3542. }
  3543. }
  3544. }
  3545. }
  3546. // on d�termine, pour les cases sans rowspan, la hauteur maximale de chaque colone
  3547. $sh = array();
  3548. for($y=0; $y<count($corr); $y++)
  3549. {
  3550. $m=0;
  3551. for($x=0; $x<count($corr[0]); $x++)
  3552. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]==1)
  3553. $m = max($m, $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h']);
  3554. $sh[$y] = $m;
  3555. }
  3556. // on v�rifie que cette taille est valide avec les lignes en rowspan
  3557. for($y=0; $y<count($corr); $y++)
  3558. {
  3559. for($x=0; $x<count($corr[0]); $x++)
  3560. {
  3561. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]) && $corr[$y][$x][3]>1)
  3562. {
  3563. // somme des colonnes correspondant au colspan
  3564. $s = 0; for($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
  3565. // si la somme est inf�rieure � la taille necessaire => r�gle de 3 pour adapter
  3566. if ($s>0 && $s<$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'])
  3567. for($i=0; $i<$corr[$y][$x][3]; $i++)
  3568. $sh[$y+$i] = $sh[$y+$i]/$s*$cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'];
  3569. }
  3570. }
  3571. }
  3572. // on applique les nouvelles hauteurs
  3573. for($y=0; $y<count($corr); $y++)
  3574. {
  3575. for($x=0; $x<count($corr[0]); $x++)
  3576. {
  3577. if (isset($corr[$y][$x]) && is_array($corr[$y][$x]))
  3578. {
  3579. if ($corr[$y][$x][3]==1)
  3580. {
  3581. $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $sh[$y];
  3582. }
  3583. else
  3584. {
  3585. // somme des lignes correspondant au rowspan
  3586. $s = 0; for($i=0; $i<$corr[$y][$x][3]; $i++) $s+= $sh[$y+$i];
  3587. $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['h'] = $s;
  3588. for($j=1; $j<$corr[$y][$x][3]; $j++)
  3589. {
  3590. $tx = $x+1;
  3591. $ty = $y+$j;
  3592. for(true; isset($corr[$ty][$tx]) && !is_array($corr[$ty][$tx]); $tx++);
  3593. if (isset($corr[$ty][$tx])) $cases[$corr[$ty][$tx][1]][$corr[$ty][$tx][0]]['dw']+= $cases[$corr[$y][$x][1]][$corr[$y][$x][0]]['w'];
  3594. }
  3595. }
  3596. }
  3597. }
  3598. }
  3599. }
  3600. /**
  3601. * balise : TH
  3602. * mode : OUVERTURE
  3603. *
  3604. * @param array param�tres de l'�l�ment de parsing
  3605. * @return null
  3606. */
  3607. function o_TH($param)
  3608. {
  3609. if ($this->forOneLine) return false;
  3610. $this->maxH = 0;
  3611. // identique � TD mais en gras
  3612. if (!isset($param['style']['font-weight'])) $param['style']['font-weight'] = 'bold';
  3613. $this->o_TD($param, 'th');
  3614. return true;
  3615. }
  3616. /**
  3617. * balise : TH
  3618. * mode : FERMETURE
  3619. *
  3620. * @param array param�tres de l'�l�ment de parsing
  3621. * @return null
  3622. */
  3623. function c_TH($param)
  3624. {
  3625. if ($this->forOneLine) return false;
  3626. $this->maxH = 0;
  3627. // identique � TD
  3628. $this->c_TD($param);
  3629. return true;
  3630. }
  3631. /**
  3632. * balise : IMG
  3633. * mode : OUVERTURE
  3634. *
  3635. * @param array param�tres de l'�l�ment de parsing
  3636. * @return null
  3637. */
  3638. function o_IMG($param)
  3639. {
  3640. // analyse du style
  3641. $src = str_replace('&amp;', '&', $param['src']);
  3642. $this->style->save();
  3643. $this->style->value['width'] = 0;
  3644. $this->style->value['height'] = 0;
  3645. $this->style->value['border'] = array(
  3646. 'type' => 'none',
  3647. 'width' => 0,
  3648. 'color' => array(0, 0, 0),
  3649. );
  3650. $this->style->value['background'] = array(
  3651. 'color' => null,
  3652. 'image' => null,
  3653. 'position' => null,
  3654. 'repeat' => null
  3655. );
  3656. $this->style->analyse('img', $param);
  3657. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3658. $this->style->FontSet();
  3659. // affichage de l'image
  3660. $this->Image($src, isset($param['sub_li']));
  3661. // restauration du style
  3662. $this->style->load();
  3663. $this->style->FontSet();
  3664. return true;
  3665. }
  3666. /**
  3667. * balise : SELECT
  3668. * mode : OUVERTURE
  3669. *
  3670. * @param array param�tres de l'�l�ment de parsing
  3671. * @return null
  3672. */
  3673. function o_SELECT($param)
  3674. {
  3675. // preparation du champs
  3676. if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps)+1);
  3677. $param['name'] = strtolower($param['name']);
  3678. if (isset($this->champs[$param['name']]))
  3679. $this->champs[$param['name']]++;
  3680. else
  3681. $this->champs[$param['name']] = 1;
  3682. $this->style->save();
  3683. $this->style->analyse('select', $param);
  3684. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3685. $this->style->FontSet();
  3686. $this->lstSelect = array();
  3687. $this->lstSelect['name'] = $param['name'];
  3688. $this->lstSelect['multi'] = isset($param['multiple']) ? true : false;
  3689. $this->lstSelect['size'] = isset($param['size']) ? $param['size'] : 1;
  3690. $this->lstSelect['options'] = array();
  3691. if ($this->lstSelect['multi'] && $this->lstSelect['size']<3) $this->lstSelect['size'] = 3;
  3692. return true;
  3693. }
  3694. /**
  3695. * balise : OPTION
  3696. * mode : OUVERTURE
  3697. *
  3698. * @param array param�tres de l'�l�ment de parsing
  3699. * @return null
  3700. */
  3701. function o_OPTION($param)
  3702. {
  3703. // on extrait tout ce qui est contenu dans l'option
  3704. $res = $this->parsing->getLevel($this->parse_pos);
  3705. $this->parse_pos = $res[0]-2;
  3706. $texte = $res[1];
  3707. $value = isset($param['value']) ? $param['value'] : 'auto_opt_'.(count($this->lstSelect)+1);
  3708. $this->lstSelect['options'][$value] = $texte;
  3709. return true;
  3710. }
  3711. /**
  3712. * balise : OPTION
  3713. * mode : FERMETURE
  3714. *
  3715. * @param array param�tres de l'�l�ment de parsing
  3716. * @return null
  3717. */
  3718. function c_OPTION($param) { return true; }
  3719. /**
  3720. * balise : SELECT
  3721. * mode : FERMETURE
  3722. *
  3723. * @param array param�tres de l'�l�ment de parsing
  3724. * @return null
  3725. */
  3726. function c_SELECT()
  3727. {
  3728. // position d'affichage
  3729. $x = $this->pdf->getX();
  3730. $y = $this->pdf->getY();
  3731. $f = 1.08*$this->style->value['font-size'];
  3732. $w = $this->style->value['width']; if (!$w) $w = 50;
  3733. $h = ($f*1.07*$this->lstSelect['size'] + 1);
  3734. $prop = array();
  3735. if ($this->lstSelect['multi']) $prop['multipleSelection'] = true;
  3736. $this->pdf->form_Select($this->lstSelect['name'], $x, $y, $w, $h, $this->lstSelect['options'], $this->lstSelect['size']>1, $prop);
  3737. $this->maxX = max($this->maxX, $x+$w);
  3738. $this->maxY = max($this->maxY, $y+$h);
  3739. $this->maxH = max($this->maxH, $h);
  3740. $this->pdf->setX($x+$w);
  3741. $this->style->load();
  3742. $this->style->FontSet();
  3743. $this->lstSelect = array();
  3744. return true;
  3745. }
  3746. /**
  3747. * balise : TEXTAREA
  3748. * mode : OUVERTURE
  3749. *
  3750. * @param array param�tres de l'�l�ment de parsing
  3751. * @return null
  3752. */
  3753. function o_TEXTAREA($param)
  3754. {
  3755. // preparation du champs
  3756. if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps)+1);
  3757. $param['name'] = strtolower($param['name']);
  3758. if (isset($this->champs[$param['name']]))
  3759. $this->champs[$param['name']]++;
  3760. else
  3761. $this->champs[$param['name']] = 1;
  3762. $this->style->save();
  3763. $this->style->analyse('textarea', $param);
  3764. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3765. $this->style->FontSet();
  3766. // position d'affichage
  3767. $x = $this->pdf->getX();
  3768. $y = $this->pdf->getY();
  3769. $fx = 0.65*$this->style->value['font-size'];
  3770. $fy = 1.08*$this->style->value['font-size'];
  3771. // on extrait tout ce qui est contenu dans le textarea
  3772. $res = $this->parsing->getLevel($this->parse_pos);
  3773. $this->parse_pos = $res[0]-2;
  3774. $texte = $res[1];
  3775. $w = $fx*(isset($param['cols']) ? $param['cols'] : 22)+1;
  3776. $h = $fy*1.07*(isset($param['rows']) ? $param['rows'] : 3)+3;
  3777. // if ($this->style->value['width']) $w = $this->style->value['width'];
  3778. // if ($this->style->value['height']) $h = $this->style->value['height'];
  3779. $prop = array();
  3780. $prop['value'] = $texte;
  3781. $prop['multiline'] = true;
  3782. $this->pdf->form_InputText($param['name'], $x, $y, $w, $h, $prop);
  3783. $this->maxX = max($this->maxX, $x+$w);
  3784. $this->maxY = max($this->maxY, $y+$h);
  3785. $this->maxH = max($this->maxH, $h);
  3786. $this->pdf->setX($x+$w);
  3787. return true;
  3788. }
  3789. /**
  3790. * balise : TEXTAREA
  3791. * mode : FERMETURE
  3792. *
  3793. * @param array param�tres de l'�l�ment de parsing
  3794. * @return null
  3795. */
  3796. function c_TEXTAREA()
  3797. {
  3798. $this->style->load();
  3799. $this->style->FontSet();
  3800. return true;
  3801. }
  3802. /**
  3803. * balise : INPUT
  3804. * mode : OUVERTURE
  3805. *
  3806. * @param array param�tres de l'�l�ment de parsing
  3807. * @return null
  3808. */
  3809. function o_INPUT($param)
  3810. {
  3811. // preparation du champs
  3812. if (!isset($param['name'])) $param['name'] = 'champs_pdf_'.(count($this->lstChamps)+1);
  3813. if (!isset($param['value'])) $param['value'] = '';
  3814. if (!isset($param['type'])) $param['type'] = 'text';
  3815. $param['name'] = strtolower($param['name']);
  3816. $param['type'] = strtolower($param['type']);
  3817. if (!in_array($param['type'], array('text', 'checkbox', 'radio', 'hidden', 'submit', 'reset', 'button'))) $param['type'] = 'text';
  3818. if (isset($this->champs[$param['name']]))
  3819. $this->champs[$param['name']]++;
  3820. else
  3821. $this->champs[$param['name']] = 1;
  3822. $this->style->save();
  3823. $this->style->analyse('input', $param);
  3824. $this->style->setPosition($this->pdf->x, $this->pdf->y);
  3825. $this->style->FontSet();
  3826. $name = $param['name'];
  3827. // position d'affichage
  3828. $x = $this->pdf->getX();
  3829. $y = $this->pdf->getY();
  3830. $f = 1.08*$this->style->value['font-size'];
  3831. switch($param['type'])
  3832. {
  3833. case 'checkbox':
  3834. $w = 3;
  3835. $h = $w;
  3836. if ($h<$f) $y+= ($f-$h)*0.5;
  3837. $this->pdf->form_InputCheckBox($name, $x, $y, $w, isset($param['checked']));
  3838. break;
  3839. case 'radio':
  3840. $w = 3;
  3841. $h = $w;
  3842. if ($h<$f) $y+= ($f-$h)*0.5;
  3843. $this->pdf->form_InputRadio($name, $x, $y, $w);
  3844. break;
  3845. case 'hidden':
  3846. $w = 0;
  3847. $h = 0;
  3848. $this->pdf->form_InputHidden($name, $param['value']);
  3849. break;
  3850. case 'text':
  3851. $w = $this->style->value['width']; if (!$w) $w = 40;
  3852. $h = $f*1.3;
  3853. $prop = array();
  3854. $prop['value'] = $param['value'];
  3855. $this->pdf->form_InputText($name, $x, $y, $w, $h, $prop);
  3856. break;
  3857. case 'submit':
  3858. case 'reset':
  3859. case 'button':
  3860. $action = isset($param['onclick']) ? $param['onclick'] : '';
  3861. $w = $this->style->value['width']; if (!$w) $w = 40;
  3862. $h = $this->style->value['height']; if (!$h) $h = $f*1.3;
  3863. $prop = array();
  3864. $this->pdf->form_InputButton($name, $x, $y, $w, $h, $param['value'], $action, $prop);
  3865. break;
  3866. default:
  3867. $w = 0;
  3868. $h = 0;
  3869. break;
  3870. }
  3871. $this->maxX = max($this->maxX, $x+$w);
  3872. $this->maxY = max($this->maxY, $y+$h);
  3873. $this->maxH = max($this->maxH, $h);
  3874. $this->pdf->setX($x+$w);
  3875. $this->style->load();
  3876. $this->style->FontSet();
  3877. return true;
  3878. }
  3879. function CreateIndex($titre = 'Index', $size_title = 20, $size_bookmark = 15, $bookmark_title = true, $display_page = true)
  3880. {
  3881. $this->pdf->CreateIndex($this, $titre, $size_title, $size_bookmark, $bookmark_title, $display_page);
  3882. }
  3883. function textLOAD($langue)
  3884. {
  3885. if (!preg_match('/^([a-z0-9]+)$/isU', $langue))
  3886. {
  3887. echo 'ERROR : language code <b>'.$langue.'</b> incorrect.';
  3888. exit;
  3889. }
  3890. $file = dirname(__FILE__).'/langues/'.strtolower($langue).'.txt';
  3891. if (!is_file($file))
  3892. {
  3893. echo 'ERROR : language code <b>'.$langue.'</b> unknown.<br>';
  3894. echo 'You can create the translation file <b>'.$file.'</b> and send it to me in order to integrate it into a future version.';
  3895. exit;
  3896. }
  3897. $texte = array();
  3898. $infos = file($file);
  3899. foreach($infos as $val)
  3900. {
  3901. $val = trim($val);
  3902. $val = explode("\t", $val);
  3903. if (count($val)<2) continue;
  3904. $t_k = trim($val[0]); unset($val[0]);
  3905. $t_v = trim(implode(' ', $val));
  3906. if ($t_k && $t_v) $texte[$t_k] = $t_v;
  3907. }
  3908. global $HTML2PDF_TEXTE_FILE;
  3909. $HTML2PDF_TEXTE_FILE = $texte;
  3910. }
  3911. function textGET($key)
  3912. {
  3913. global $HTML2PDF_TEXTE_FILE;
  3914. if (!isset($HTML2PDF_TEXTE_FILE[$key])) return '######';
  3915. return $HTML2PDF_TEXTE_FILE[$key];
  3916. }
  3917. function makeError($err, $file, $line, $other = null)
  3918. {
  3919. $msg = '';
  3920. switch($err)
  3921. {
  3922. case 1:
  3923. $msg = (@HTML2PDF::textGET('err01'));
  3924. $msg = str_replace('[[OTHER]]', $other, $msg);
  3925. break;
  3926. case 2:
  3927. $msg = (@HTML2PDF::textGET('err02'));
  3928. $msg = str_replace('[[OTHER_0]]', $other[0], $msg);
  3929. $msg = str_replace('[[OTHER_1]]', $other[1], $msg);
  3930. $msg = str_replace('[[OTHER_2]]', $other[2], $msg);
  3931. break;
  3932. case 3:
  3933. $msg = (@HTML2PDF::textGET('err03'));
  3934. $msg = str_replace('[[OTHER]]', $other, $msg);
  3935. break;
  3936. case 4:
  3937. $msg = (@HTML2PDF::textGET('err04'));
  3938. $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
  3939. break;
  3940. case 5:
  3941. $msg = (@HTML2PDF::textGET('err05'));
  3942. $msg = str_replace('[[OTHER]]', print_r($other, true), $msg);
  3943. break;
  3944. case 6:
  3945. $msg = (@HTML2PDF::textGET('err06'));
  3946. $msg = str_replace('[[OTHER]]', $other, $msg);
  3947. break;
  3948. case 7:
  3949. $msg = (@HTML2PDF::textGET('err07'));
  3950. break;
  3951. }
  3952. $Dokeosmsg = '<div style="position: relative; margin-top: 10px; margin-bottom: 10px; border-width: 1px; border-style: solid; padding: 5px; border: 1px solid #FF0000; color: #000; background-color: #FFD1D1; min-height: 30px;"><b>'.get_lang("ConversionFailled").'</b></br>'.get_lang("CommentErrorExportDocument").'</div>';
  3953. echo $Dokeosmsg;
  3954. /*
  3955. ////uncomment for debug
  3956. echo '<span style="color: #AA0000; font-weight: bold;">'.(@HTML2PDF::textGET('txt01')).$err.'</span><br>';
  3957. echo (@HTML2PDF::textGET('txt02')).' '.$file.'<br>';
  3958. echo (@HTML2PDF::textGET('txt03')).' '.$line.'<br>';
  3959. echo '<br>';
  3960. echo $msg;
  3961. */
  3962. exit;
  3963. }
  3964. }
  3965. }