Tag.php 256 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118
  1. <?php
  2. class Tag
  3. {
  4. private $mpdf;
  5. public function __construct(mPDF $mpdf)
  6. {
  7. $this->mpdf = $mpdf;
  8. }
  9. function OpenTag($tag, $attr, &$ahtml, &$ihtml)
  10. { // mPDF 6
  11. //Opening tag
  12. // mPDF 6
  13. // Correct for tags where HTML5 specifies optional end tags excluding table elements (cf WriteHTML() )
  14. if ($this->mpdf->allow_html_optional_endtags) {
  15. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['tag'])) {
  16. $closed = false;
  17. // li end tag may be omitted if immediately followed by another li element
  18. if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'LI' && $tag == 'LI') {
  19. $this->CloseTag('LI', $ahtml, $ihtml);
  20. $closed = true;
  21. }
  22. // dt end tag may be omitted if immediately followed by another dt element or a dd element
  23. if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DT' && ($tag == 'DT' || $tag == 'DD')) {
  24. $this->CloseTag('DT', $ahtml, $ihtml);
  25. $closed = true;
  26. }
  27. // dd end tag may be omitted if immediately followed by another dd element or a dt element
  28. if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DD' && ($tag == 'DT' || $tag == 'DD')) {
  29. $this->CloseTag('DD', $ahtml, $ihtml);
  30. $closed = true;
  31. }
  32. // p end tag may be omitted if immediately followed by an address, article, aside, blockquote, div, dl, fieldset, form,
  33. // h1, h2, h3, h4, h5, h6, hgroup, hr, main, nav, ol, p, pre, section, table, ul
  34. if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'P' && ($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag == 'PRE' || $tag == 'FORM' || $tag == 'ADDRESS' || $tag == 'BLOCKQUOTE' || $tag == 'CENTER' || $tag == 'DL' || $tag == 'HR' || $tag == 'ARTICLE' || $tag == 'ASIDE' || $tag == 'FIELDSET' || $tag == 'HGROUP' || $tag == 'MAIN' || $tag == 'NAV' || $tag == 'SECTION')) {
  35. $this->CloseTag('P', $ahtml, $ihtml);
  36. $closed = true;
  37. }
  38. // option end tag may be omitted if immediately followed by another option element (or if it is immediately followed by an optgroup element)
  39. if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'OPTION' && $tag == 'OPTION') {
  40. $this->CloseTag('OPTION', $ahtml, $ihtml);
  41. $closed = true;
  42. }
  43. // Table elements - see also WriteHTML()
  44. if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TD') {
  45. $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
  46. $closed = true;
  47. } // *TABLES*
  48. if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TH') {
  49. $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
  50. $closed = true;
  51. } // *TABLES*
  52. if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TR') {
  53. $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
  54. $closed = true;
  55. } // *TABLES*
  56. if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TD') {
  57. $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
  58. $this->CloseTag('TR', $ahtml, $ihtml);
  59. $this->CloseTag('THEAD', $ahtml, $ihtml);
  60. $closed = true;
  61. } // *TABLES*
  62. if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TH') {
  63. $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
  64. $this->CloseTag('TR', $ahtml, $ihtml);
  65. $this->CloseTag('THEAD', $ahtml, $ihtml);
  66. $closed = true;
  67. } // *TABLES*
  68. }
  69. }
  70. $align = array('left' => 'L', 'center' => 'C', 'right' => 'R', 'top' => 'T', 'text-top' => 'TT', 'middle' => 'M', 'baseline' => 'BS', 'bottom' => 'B', 'text-bottom' => 'TB', 'justify' => 'J');
  71. switch ($tag) {
  72. case 'DOTTAB':
  73. $objattr = array();
  74. $objattr['type'] = 'dottab';
  75. $dots = str_repeat('.', 3) . " "; // minimum number of dots
  76. $objattr['width'] = $this->mpdf->GetStringWidth($dots);
  77. $objattr['margin_top'] = 0;
  78. $objattr['margin_bottom'] = 0;
  79. $objattr['margin_left'] = 0;
  80. $objattr['margin_right'] = 0;
  81. $objattr['height'] = 0;
  82. $objattr['colorarray'] = $this->mpdf->colorarray;
  83. $objattr['border_top']['w'] = 0;
  84. $objattr['border_bottom']['w'] = 0;
  85. $objattr['border_left']['w'] = 0;
  86. $objattr['border_right']['w'] = 0;
  87. $objattr['vertical_align'] = 'BS'; // mPDF 6 DOTTAB
  88. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  89. if (isset($properties['OUTDENT'])) {
  90. $objattr['outdent'] = $this->mpdf->ConvertSize($properties['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  91. } else if (isset($attr['OUTDENT'])) {
  92. $objattr['outdent'] = $this->mpdf->ConvertSize($attr['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  93. } else {
  94. $objattr['outdent'] = 0;
  95. }
  96. $objattr['fontfamily'] = $this->mpdf->FontFamily;
  97. $objattr['fontsize'] = $this->mpdf->FontSizePt;
  98. $e = "\xbb\xa4\xactype=dottab,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  99. /* -- TABLES -- */
  100. // Output it to buffers
  101. if ($this->mpdf->tableLevel) {
  102. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  103. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  104. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  105. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  106. }
  107. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
  108. $this->mpdf->_saveCellTextBuffer($e);
  109. } else {
  110. /* -- END TABLES -- */
  111. $this->mpdf->_saveTextBuffer($e);
  112. } // *TABLES*
  113. break;
  114. case 'PAGEHEADER':
  115. case 'PAGEFOOTER':
  116. $this->mpdf->ignorefollowingspaces = true;
  117. if ($attr['NAME']) {
  118. $pname = $attr['NAME'];
  119. } else {
  120. $pname = '_nonhtmldefault';
  121. } // mPDF 6
  122. $p = array(); // mPDF 6
  123. $p['L'] = array();
  124. $p['C'] = array();
  125. $p['R'] = array();
  126. $p['L']['font-style'] = '';
  127. $p['C']['font-style'] = '';
  128. $p['R']['font-style'] = '';
  129. if (isset($attr['CONTENT-LEFT'])) {
  130. $p['L']['content'] = $attr['CONTENT-LEFT'];
  131. }
  132. if (isset($attr['CONTENT-CENTER'])) {
  133. $p['C']['content'] = $attr['CONTENT-CENTER'];
  134. }
  135. if (isset($attr['CONTENT-RIGHT'])) {
  136. $p['R']['content'] = $attr['CONTENT-RIGHT'];
  137. }
  138. if (isset($attr['HEADER-STYLE']) || isset($attr['FOOTER-STYLE'])) { // font-family,size,weight,style,color
  139. if ($tag == 'PAGEHEADER') {
  140. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE']);
  141. } else {
  142. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE']);
  143. }
  144. if (isset($properties['FONT-FAMILY'])) {
  145. $p['L']['font-family'] = $properties['FONT-FAMILY'];
  146. $p['C']['font-family'] = $properties['FONT-FAMILY'];
  147. $p['R']['font-family'] = $properties['FONT-FAMILY'];
  148. }
  149. if (isset($properties['FONT-SIZE'])) {
  150. $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  151. $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  152. $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  153. }
  154. if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
  155. $p['L']['font-style'] = 'B';
  156. $p['C']['font-style'] = 'B';
  157. $p['R']['font-style'] = 'B';
  158. }
  159. if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
  160. $p['L']['font-style'] .= 'I';
  161. $p['C']['font-style'] .= 'I';
  162. $p['R']['font-style'] .= 'I';
  163. }
  164. if (isset($properties['COLOR'])) {
  165. $p['L']['color'] = $properties['COLOR'];
  166. $p['C']['color'] = $properties['COLOR'];
  167. $p['R']['color'] = $properties['COLOR'];
  168. }
  169. }
  170. if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) {
  171. if ($tag == 'PAGEHEADER') {
  172. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-LEFT']);
  173. } else {
  174. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-LEFT']);
  175. }
  176. if (isset($properties['FONT-FAMILY'])) {
  177. $p['L']['font-family'] = $properties['FONT-FAMILY'];
  178. }
  179. if (isset($properties['FONT-SIZE'])) {
  180. $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  181. }
  182. if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
  183. $p['L']['font-style'] = 'B';
  184. }
  185. if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
  186. $p['L']['font-style'] .='I';
  187. }
  188. if (isset($properties['COLOR'])) {
  189. $p['L']['color'] = $properties['COLOR'];
  190. }
  191. }
  192. if (isset($attr['HEADER-STYLE-CENTER']) || isset($attr['FOOTER-STYLE-CENTER'])) {
  193. if ($tag == 'PAGEHEADER') {
  194. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-CENTER']);
  195. } else {
  196. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-CENTER']);
  197. }
  198. if (isset($properties['FONT-FAMILY'])) {
  199. $p['C']['font-family'] = $properties['FONT-FAMILY'];
  200. }
  201. if (isset($properties['FONT-SIZE'])) {
  202. $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  203. }
  204. if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
  205. $p['C']['font-style'] = 'B';
  206. }
  207. if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
  208. $p['C']['font-style'] .= 'I';
  209. }
  210. if (isset($properties['COLOR'])) {
  211. $p['C']['color'] = $properties['COLOR'];
  212. }
  213. }
  214. if (isset($attr['HEADER-STYLE-RIGHT']) || isset($attr['FOOTER-STYLE-RIGHT'])) {
  215. if ($tag == 'PAGEHEADER') {
  216. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-RIGHT']);
  217. } else {
  218. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-RIGHT']);
  219. }
  220. if (isset($properties['FONT-FAMILY'])) {
  221. $p['R']['font-family'] = $properties['FONT-FAMILY'];
  222. }
  223. if (isset($properties['FONT-SIZE'])) {
  224. $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
  225. }
  226. if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
  227. $p['R']['font-style'] = 'B';
  228. }
  229. if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
  230. $p['R']['font-style'] .= 'I';
  231. }
  232. if (isset($properties['COLOR'])) {
  233. $p['R']['color'] = $properties['COLOR'];
  234. }
  235. }
  236. if (isset($attr['LINE']) && $attr['LINE']) { // 0|1|on|off
  237. if ($attr['LINE'] == '1' || strtoupper($attr['LINE']) == 'ON') {
  238. $lineset = 1;
  239. } else {
  240. $lineset = 0;
  241. }
  242. $p['line'] = $lineset;
  243. }
  244. // mPDF 6
  245. if ($tag == 'PAGEHEADER') {
  246. $this->mpdf->DefHeaderByName($pname, $p);
  247. } else {
  248. $this->mpdf->DefFooterByName($pname, $p);
  249. }
  250. break;
  251. case 'SETPAGEHEADER': // mPDF 6
  252. case 'SETPAGEFOOTER':
  253. case 'SETHTMLPAGEHEADER':
  254. case 'SETHTMLPAGEFOOTER':
  255. $this->mpdf->ignorefollowingspaces = true;
  256. if (isset($attr['NAME']) && $attr['NAME']) {
  257. $pname = $attr['NAME'];
  258. } else if ($tag == 'SETPAGEHEADER' || $tag == 'SETPAGEFOOTER') {
  259. $pname = '_nonhtmldefault';
  260. } // mPDF 6
  261. else {
  262. $pname = '_default';
  263. }
  264. if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
  265. if (strtoupper($attr['PAGE']) == 'O' || strtoupper($attr['PAGE']) == 'ODD') {
  266. $side = 'odd';
  267. } else if (strtoupper($attr['PAGE']) == 'E' || strtoupper($attr['PAGE']) == 'EVEN') {
  268. $side = 'even';
  269. } else if (strtoupper($attr['PAGE']) == 'ALL') {
  270. $side = 'both';
  271. } else {
  272. $side = 'odd';
  273. }
  274. } else {
  275. $side = 'odd';
  276. }
  277. if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off
  278. if ($attr['VALUE'] == '1' || strtoupper($attr['VALUE']) == 'ON') {
  279. $set = 1;
  280. } else if ($attr['VALUE'] == '-1' || strtoupper($attr['VALUE']) == 'OFF') {
  281. $set = 0;
  282. } else {
  283. $set = 1;
  284. }
  285. } else {
  286. $set = 1;
  287. }
  288. if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
  289. $write = 1;
  290. } else {
  291. $write = 0;
  292. }
  293. if ($side == 'odd' || $side == 'both') {
  294. if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
  295. $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'O', $write);
  296. } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) {
  297. $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'O');
  298. } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') {
  299. $this->mpdf->SetHTMLHeader('', 'O');
  300. } else {
  301. $this->mpdf->SetHTMLFooter('', 'O');
  302. }
  303. }
  304. if ($side == 'even' || $side == 'both') {
  305. if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
  306. $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'E', $write);
  307. } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) {
  308. $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'E');
  309. } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') {
  310. $this->mpdf->SetHTMLHeader('', 'E');
  311. } else {
  312. $this->mpdf->SetHTMLFooter('', 'E');
  313. }
  314. }
  315. break;
  316. /* -- TOC -- */
  317. case 'TOC': //added custom-tag - set Marker for insertion later of ToC
  318. if (!class_exists('tocontents', false)) {
  319. include(_MPDF_PATH . 'classes/tocontents.php');
  320. }
  321. if (empty($this->mpdf->tocontents)) {
  322. $this->mpdf->tocontents = new tocontents($this);
  323. }
  324. $this->mpdf->tocontents->openTagTOC($attr);
  325. break;
  326. case 'TOCPAGEBREAK': // custom-tag - set Marker for insertion later of ToC AND adds PAGEBREAK
  327. if (!class_exists('tocontents', false)) {
  328. include(_MPDF_PATH . 'classes/tocontents.php');
  329. }
  330. if (empty($this->mpdf->tocontents)) {
  331. $this->mpdf->tocontents = new tocontents($this->mpdf);
  332. }
  333. list($isbreak, $toc_id) = $this->mpdf->tocontents->openTagTOCPAGEBREAK($attr);
  334. if ($isbreak)
  335. break;
  336. if (!isset($attr['RESETPAGENUM']) || $attr['RESETPAGENUM'] < 1) {
  337. $attr['RESETPAGENUM'] = 1;
  338. } // mPDF 6
  339. // No break - continues as PAGEBREAK...
  340. /* -- END TOC -- */
  341. case 'PAGE_BREAK': //custom-tag
  342. case 'PAGEBREAK': //custom-tag
  343. case 'NEWPAGE': //custom-tag
  344. case 'FORMFEED': //custom-tag
  345. if (isset($attr['SHEET-SIZE'])) {
  346. // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
  347. $prop = preg_split('/\s+/', trim($attr['SHEET-SIZE']));
  348. if (count($prop) == 2) {
  349. $newformat = array($this->mpdf->ConvertSize($prop[0]), $this->mpdf->ConvertSize($prop[1]));
  350. } else {
  351. $newformat = $attr['SHEET-SIZE'];
  352. }
  353. } else {
  354. $newformat = '';
  355. }
  356. $save_blklvl = $this->mpdf->blklvl;
  357. $save_blk = $this->mpdf->blk;
  358. $save_silp = $this->mpdf->saveInlineProperties();
  359. $save_ilp = $this->mpdf->InlineProperties;
  360. $save_bflp = $this->mpdf->InlineBDF;
  361. $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
  362. $mgr = $mgl = $mgt = $mgb = $mgh = $mgf = '';
  363. if (isset($attr['MARGIN-RIGHT'])) {
  364. $mgr = $this->mpdf->ConvertSize($attr['MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  365. }
  366. if (isset($attr['MARGIN-LEFT'])) {
  367. $mgl = $this->mpdf->ConvertSize($attr['MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false);
  368. }
  369. if (isset($attr['MARGIN-TOP'])) {
  370. $mgt = $this->mpdf->ConvertSize($attr['MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false);
  371. }
  372. if (isset($attr['MARGIN-BOTTOM'])) {
  373. $mgb = $this->mpdf->ConvertSize($attr['MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false);
  374. }
  375. if (isset($attr['MARGIN-HEADER'])) {
  376. $mgh = $this->mpdf->ConvertSize($attr['MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  377. }
  378. if (isset($attr['MARGIN-FOOTER'])) {
  379. $mgf = $this->mpdf->ConvertSize($attr['MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false);
  380. }
  381. $ohname = $ehname = $ofname = $efname = '';
  382. if (isset($attr['ODD-HEADER-NAME'])) {
  383. $ohname = $attr['ODD-HEADER-NAME'];
  384. }
  385. if (isset($attr['EVEN-HEADER-NAME'])) {
  386. $ehname = $attr['EVEN-HEADER-NAME'];
  387. }
  388. if (isset($attr['ODD-FOOTER-NAME'])) {
  389. $ofname = $attr['ODD-FOOTER-NAME'];
  390. }
  391. if (isset($attr['EVEN-FOOTER-NAME'])) {
  392. $efname = $attr['EVEN-FOOTER-NAME'];
  393. }
  394. $ohvalue = $ehvalue = $ofvalue = $efvalue = 0;
  395. if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'ON')) {
  396. $ohvalue = 1;
  397. } else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'OFF')) {
  398. $ohvalue = -1;
  399. }
  400. if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'ON')) {
  401. $ehvalue = 1;
  402. } else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'OFF')) {
  403. $ehvalue = -1;
  404. }
  405. if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'ON')) {
  406. $ofvalue = 1;
  407. } else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'OFF')) {
  408. $ofvalue = -1;
  409. }
  410. if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'ON')) {
  411. $efvalue = 1;
  412. } else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'OFF')) {
  413. $efvalue = -1;
  414. }
  415. if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'L' || strtoupper($attr['ORIENTATION']) == 'LANDSCAPE')) {
  416. $orient = 'L';
  417. } else if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'P' || strtoupper($attr['ORIENTATION']) == 'PORTRAIT')) {
  418. $orient = 'P';
  419. } else {
  420. $orient = $this->mpdf->CurOrientation;
  421. }
  422. if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) {
  423. $pagesel = $attr['PAGE-SELECTOR'];
  424. } else {
  425. $pagesel = '';
  426. }
  427. // mPDF 6 pagebreaktype
  428. $pagebreaktype = $this->mpdf->defaultPagebreakType;
  429. if ($tag == 'FORMFEED') {
  430. $pagebreaktype = 'slice';
  431. } // can be overridden by PAGE-BREAK-TYPE
  432. $startpage = $this->mpdf->page;
  433. if (isset($attr['PAGE-BREAK-TYPE'])) {
  434. if (strtolower($attr['PAGE-BREAK-TYPE']) == 'cloneall' || strtolower($attr['PAGE-BREAK-TYPE']) == 'clonebycss' || strtolower($attr['PAGE-BREAK-TYPE']) == 'slice') {
  435. $pagebreaktype = strtolower($attr['PAGE-BREAK-TYPE']);
  436. }
  437. }
  438. if ($tag == 'TOCPAGEBREAK') {
  439. $pagebreaktype = 'cloneall';
  440. } else if ($this->mpdf->ColActive) {
  441. $pagebreaktype = 'cloneall';
  442. }
  443. // Any change in headers/footers (may need to _getHtmlHeight), or page size/orientation, @page selector, or margins - force cloneall
  444. else if ($mgr !== '' || $mgl !== '' || $mgt !== '' || $mgb !== '' || $mgh !== '' || $mgf !== '' ||
  445. $ohname !== '' || $ehname !== '' || $ofname !== '' || $efname !== '' ||
  446. $ohvalue || $ehvalue || $ofvalue || $efvalue ||
  447. $orient != $this->mpdf->CurOrientation || $newformat || $pagesel) {
  448. $pagebreaktype = 'cloneall';
  449. }
  450. // mPDF 6 pagebreaktype
  451. $this->mpdf->_preForcedPagebreak($pagebreaktype);
  452. $this->mpdf->ignorefollowingspaces = true;
  453. $resetpagenum = '';
  454. $pagenumstyle = '';
  455. $suppress = '';
  456. if (isset($attr['RESETPAGENUM'])) {
  457. $resetpagenum = $attr['RESETPAGENUM'];
  458. }
  459. if (isset($attr['PAGENUMSTYLE'])) {
  460. $pagenumstyle = $attr['PAGENUMSTYLE'];
  461. }
  462. if (isset($attr['SUPPRESS'])) {
  463. $suppress = $attr['SUPPRESS'];
  464. }
  465. if ($tag == 'TOCPAGEBREAK') {
  466. $type = 'NEXT-ODD';
  467. } else if (isset($attr['TYPE'])) {
  468. $type = strtoupper($attr['TYPE']);
  469. } else {
  470. $type = '';
  471. }
  472. if ($type == 'E' || $type == 'EVEN') {
  473. $this->mpdf->AddPage($orient, 'E', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  474. } else if ($type == 'O' || $type == 'ODD') {
  475. $this->mpdf->AddPage($orient, 'O', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  476. } else if ($type == 'NEXT-ODD') {
  477. $this->mpdf->AddPage($orient, 'NEXT-ODD', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  478. } else if ($type == 'NEXT-EVEN') {
  479. $this->mpdf->AddPage($orient, 'NEXT-EVEN', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  480. } else {
  481. $this->mpdf->AddPage($orient, '', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  482. }
  483. /* -- TOC -- */
  484. if ($tag == 'TOCPAGEBREAK') {
  485. if ($toc_id) {
  486. $this->mpdf->tocontents->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
  487. } else {
  488. $this->mpdf->tocontents->TOCmark = $this->mpdf->page;
  489. }
  490. }
  491. /* -- END TOC -- */
  492. // mPDF 6 pagebreaktype
  493. $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
  494. $this->mpdf->InlineProperties = $save_ilp;
  495. $this->mpdf->InlineBDF = $save_bflp;
  496. $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
  497. $this->mpdf->restoreInlineProperties($save_silp);
  498. break;
  499. /* -- TOC -- */
  500. case 'TOCENTRY':
  501. if (isset($attr['CONTENT']) && $attr['CONTENT']) {
  502. $objattr = array();
  503. $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
  504. $objattr['type'] = 'toc';
  505. $objattr['vertical-align'] = 'T';
  506. if (isset($attr['LEVEL']) && $attr['LEVEL']) {
  507. $objattr['toclevel'] = $attr['LEVEL'];
  508. } else {
  509. $objattr['toclevel'] = 0;
  510. }
  511. if (isset($attr['NAME']) && $attr['NAME']) {
  512. $objattr['toc_id'] = $attr['NAME'];
  513. } else {
  514. $objattr['toc_id'] = 0;
  515. }
  516. $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  517. if ($this->mpdf->tableLevel) {
  518. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
  519. } // *TABLES*
  520. else { // *TABLES*
  521. $this->mpdf->textbuffer[] = array($e);
  522. } // *TABLES*
  523. }
  524. break;
  525. /* -- END TOC -- */
  526. /* -- INDEX -- */
  527. case 'INDEXENTRY':
  528. if (isset($attr['CONTENT']) && $attr['CONTENT']) {
  529. if (isset($attr['XREF']) && $attr['XREF']) {
  530. $this->mpdf->IndexEntry(htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES), $attr['XREF']);
  531. break;
  532. }
  533. $objattr = array();
  534. $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
  535. $objattr['type'] = 'indexentry';
  536. $objattr['vertical-align'] = 'T';
  537. $e = "\xbb\xa4\xactype=indexentry,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  538. if ($this->mpdf->tableLevel) {
  539. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
  540. } // *TABLES*
  541. else { // *TABLES*
  542. $this->mpdf->textbuffer[] = array($e);
  543. } // *TABLES*
  544. }
  545. break;
  546. case 'INDEXINSERT':
  547. if (isset($attr['COLLATION'])) {
  548. $indexCollationLocale = $attr['COLLATION'];
  549. } else {
  550. $indexCollationLocale = '';
  551. }
  552. if (isset($attr['COLLATION-GROUP'])) {
  553. $indexCollationGroup = $attr['COLLATION-GROUP'];
  554. } else {
  555. $indexCollationGroup = '';
  556. }
  557. if (isset($attr['USEDIVLETTERS']) && (strtoupper($attr['USEDIVLETTERS']) == 'OFF' || $attr['USEDIVLETTERS'] == -1 || $attr['USEDIVLETTERS'] === '0')) {
  558. $usedivletters = 0;
  559. } else {
  560. $usedivletters = 1;
  561. }
  562. if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) {
  563. $links = true;
  564. } else {
  565. $links = false;
  566. }
  567. $this->mpdf->InsertIndex($usedivletters, $links, $indexCollationLocale, $indexCollationGroup);
  568. break;
  569. /* -- END INDEX -- */
  570. /* -- WATERMARK -- */
  571. case 'WATERMARKTEXT':
  572. if (isset($attr['CONTENT']) && $attr['CONTENT']) {
  573. $txt = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
  574. } else {
  575. $txt = '';
  576. }
  577. if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
  578. $alpha = $attr['ALPHA'];
  579. } else {
  580. $alpha = -1;
  581. }
  582. $this->mpdf->SetWatermarkText($txt, $alpha);
  583. break;
  584. case 'WATERMARKIMAGE':
  585. if (isset($attr['SRC'])) {
  586. $src = $attr['SRC'];
  587. } else {
  588. $src = '';
  589. }
  590. if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
  591. $alpha = $attr['ALPHA'];
  592. } else {
  593. $alpha = -1;
  594. }
  595. if (isset($attr['SIZE']) && $attr['SIZE']) {
  596. $size = $attr['SIZE'];
  597. if (strpos($size, ',')) {
  598. $size = explode(',', $size);
  599. }
  600. } else {
  601. $size = 'D';
  602. }
  603. if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2
  604. $pos = $attr['POSITION'];
  605. if (strpos($pos, ',')) {
  606. $pos = explode(',', $pos);
  607. }
  608. } else {
  609. $pos = 'P';
  610. }
  611. $this->mpdf->SetWatermarkImage($src, $alpha, $size, $pos);
  612. break;
  613. /* -- END WATERMARK -- */
  614. /* -- BOOKMARKS -- */
  615. case 'BOOKMARK':
  616. if (isset($attr['CONTENT'])) {
  617. $objattr = array();
  618. $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
  619. $objattr['type'] = 'bookmark';
  620. if (isset($attr['LEVEL']) && $attr['LEVEL']) {
  621. $objattr['bklevel'] = $attr['LEVEL'];
  622. } else {
  623. $objattr['bklevel'] = 0;
  624. }
  625. $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  626. if ($this->mpdf->tableLevel) {
  627. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
  628. } // *TABLES*
  629. else { // *TABLES*
  630. $this->mpdf->textbuffer[] = array($e);
  631. } // *TABLES*
  632. }
  633. break;
  634. /* -- END BOOKMARKS -- */
  635. /* -- ANNOTATIONS -- */
  636. case 'ANNOTATION':
  637. //if (isset($attr['CONTENT']) && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) { // Stops annotations in FixedPos
  638. if (isset($attr['CONTENT'])) {
  639. $objattr = array();
  640. $objattr['margin_top'] = 0;
  641. $objattr['margin_bottom'] = 0;
  642. $objattr['margin_left'] = 0;
  643. $objattr['margin_right'] = 0;
  644. $objattr['width'] = 0;
  645. $objattr['height'] = 0;
  646. $objattr['border_top']['w'] = 0;
  647. $objattr['border_bottom']['w'] = 0;
  648. $objattr['border_left']['w'] = 0;
  649. $objattr['border_right']['w'] = 0;
  650. $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
  651. $objattr['type'] = 'annot';
  652. $objattr['POPUP'] = '';
  653. } else {
  654. break;
  655. }
  656. if (isset($attr['POS-X'])) {
  657. $objattr['POS-X'] = $attr['POS-X'];
  658. } else {
  659. $objattr['POS-X'] = 0;
  660. }
  661. if (isset($attr['POS-Y'])) {
  662. $objattr['POS-Y'] = $attr['POS-Y'];
  663. } else {
  664. $objattr['POS-Y'] = 0;
  665. }
  666. if (isset($attr['ICON'])) {
  667. $objattr['ICON'] = $attr['ICON'];
  668. } else {
  669. $objattr['ICON'] = 'Note';
  670. }
  671. if (isset($attr['AUTHOR'])) {
  672. $objattr['AUTHOR'] = $attr['AUTHOR'];
  673. } else if (isset($attr['TITLE'])) {
  674. $objattr['AUTHOR'] = $attr['TITLE'];
  675. } else {
  676. $objattr['AUTHOR'] = '';
  677. }
  678. if (isset($attr['FILE'])) {
  679. $objattr['FILE'] = $attr['FILE'];
  680. } else {
  681. $objattr['FILE'] = '';
  682. }
  683. if (isset($attr['SUBJECT'])) {
  684. $objattr['SUBJECT'] = $attr['SUBJECT'];
  685. } else {
  686. $objattr['SUBJECT'] = '';
  687. }
  688. if (isset($attr['OPACITY']) && $attr['OPACITY'] > 0 && $attr['OPACITY'] <= 1) {
  689. $objattr['OPACITY'] = $attr['OPACITY'];
  690. } else if ($this->mpdf->annotMargin) {
  691. $objattr['OPACITY'] = 1;
  692. } else {
  693. $objattr['OPACITY'] = $this->mpdf->annotOpacity;
  694. }
  695. if (isset($attr['COLOR'])) {
  696. $cor = $this->mpdf->ConvertColor($attr['COLOR']);
  697. if ($cor) {
  698. $objattr['COLOR'] = $cor;
  699. } else {
  700. $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
  701. }
  702. } else {
  703. $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
  704. }
  705. if (isset($attr['POPUP']) && !empty($attr['POPUP'])) {
  706. $pop = preg_split('/\s+/', trim($attr['POPUP']));
  707. if (count($pop) > 1) {
  708. $objattr['POPUP'] = $pop;
  709. } else {
  710. $objattr['POPUP'] = true;
  711. }
  712. }
  713. $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  714. if ($this->mpdf->tableLevel) {
  715. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
  716. } // *TABLES*
  717. else { // *TABLES*
  718. $this->mpdf->textbuffer[] = array($e);
  719. } // *TABLES*
  720. break;
  721. /* -- END ANNOTATIONS -- */
  722. /* -- COLUMNS -- */
  723. case 'COLUMNS': //added custom-tag
  724. if (isset($attr['COLUMN-COUNT']) && ($attr['COLUMN-COUNT'] || $attr['COLUMN-COUNT'] === '0')) {
  725. // Close any open block tags
  726. for ($b = $this->mpdf->blklvl; $b > 0; $b--) {
  727. $this->CloseTag($this->mpdf->blk[$b]['tag'], $ahtml, $ihtml);
  728. }
  729. if (!empty($this->mpdf->textbuffer)) { //Output previously buffered content
  730. $this->mpdf->printbuffer($this->mpdf->textbuffer);
  731. $this->mpdf->textbuffer = array();
  732. }
  733. if (isset($attr['VALIGN']) && $attr['VALIGN']) {
  734. if ($attr['VALIGN'] == 'J') {
  735. $valign = 'J';
  736. } else {
  737. $valign = $align[$attr['VALIGN']];
  738. }
  739. } else {
  740. $valign = '';
  741. }
  742. if (isset($attr['COLUMN-GAP']) && $attr['COLUMN-GAP']) {
  743. $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign, $attr['COLUMN-GAP']);
  744. } else {
  745. $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign);
  746. }
  747. }
  748. $this->mpdf->ignorefollowingspaces = true;
  749. break;
  750. case 'COLUMN_BREAK': //custom-tag
  751. case 'COLUMNBREAK': //custom-tag
  752. case 'NEWCOLUMN': //custom-tag
  753. $this->mpdf->ignorefollowingspaces = true;
  754. $this->mpdf->NewColumn();
  755. $this->mpdf->ColumnAdjust = false; // disables all column height adjustment for the page.
  756. break;
  757. /* -- END COLUMNS -- */
  758. case 'TTZ':
  759. $this->mpdf->ttz = true;
  760. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  761. $this->mpdf->setCSS(array('FONT-FAMILY' => 'czapfdingbats', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE');
  762. break;
  763. case 'TTS':
  764. $this->mpdf->tts = true;
  765. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  766. $this->mpdf->setCSS(array('FONT-FAMILY' => 'csymbol', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE');
  767. break;
  768. case 'TTA':
  769. $this->mpdf->tta = true;
  770. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  771. if (in_array($this->mpdf->FontFamily, $this->mpdf->mono_fonts)) {
  772. $this->mpdf->setCSS(array('FONT-FAMILY' => 'ccourier'), 'INLINE');
  773. } else if (in_array($this->mpdf->FontFamily, $this->mpdf->serif_fonts)) {
  774. $this->mpdf->setCSS(array('FONT-FAMILY' => 'ctimes'), 'INLINE');
  775. } else {
  776. $this->mpdf->setCSS(array('FONT-FAMILY' => 'chelvetica'), 'INLINE');
  777. }
  778. break;
  779. // INLINE PHRASES OR STYLES
  780. case 'SUB':
  781. case 'SUP':
  782. case 'ACRONYM':
  783. case 'BIG':
  784. case 'SMALL':
  785. case 'INS':
  786. case 'S':
  787. case 'STRIKE':
  788. case 'DEL':
  789. case 'STRONG':
  790. case 'CITE':
  791. case 'Q':
  792. case 'EM':
  793. case 'B':
  794. case 'I':
  795. case 'U':
  796. case 'SAMP':
  797. case 'CODE':
  798. case 'KBD':
  799. case 'TT':
  800. case 'VAR':
  801. case 'FONT':
  802. case 'MARK':
  803. case 'TIME':
  804. case 'BDO': // mPDF 6
  805. case 'BDI': // mPDF 6
  806. case 'SPAN':
  807. /* -- ANNOTATIONS -- */
  808. if ($this->mpdf->title2annots && isset($attr['TITLE'])) {
  809. $objattr = array();
  810. $objattr['margin_top'] = 0;
  811. $objattr['margin_bottom'] = 0;
  812. $objattr['margin_left'] = 0;
  813. $objattr['margin_right'] = 0;
  814. $objattr['width'] = 0;
  815. $objattr['height'] = 0;
  816. $objattr['border_top']['w'] = 0;
  817. $objattr['border_bottom']['w'] = 0;
  818. $objattr['border_left']['w'] = 0;
  819. $objattr['border_right']['w'] = 0;
  820. $objattr['CONTENT'] = $attr['TITLE'];
  821. $objattr['type'] = 'annot';
  822. $objattr['POS-X'] = 0;
  823. $objattr['POS-Y'] = 0;
  824. $objattr['ICON'] = 'Comment';
  825. $objattr['AUTHOR'] = '';
  826. $objattr['SUBJECT'] = '';
  827. $objattr['OPACITY'] = $this->mpdf->annotOpacity;
  828. $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
  829. $annot = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  830. }
  831. /* -- END ANNOTATIONS -- */
  832. // mPDF 5.7.3 Inline tags
  833. if (!isset($this->mpdf->InlineProperties[$tag])) {
  834. $this->mpdf->InlineProperties[$tag] = array($this->mpdf->saveInlineProperties());
  835. } else {
  836. $this->mpdf->InlineProperties[$tag][] = $this->mpdf->saveInlineProperties();
  837. }
  838. if (isset($annot)) { // *ANNOTATIONS*
  839. if (!isset($this->mpdf->InlineAnnots[$tag])) {
  840. $this->mpdf->InlineAnnots[$tag] = array($annot);
  841. } // *ANNOTATIONS*
  842. else {
  843. $this->mpdf->InlineAnnots[$tag][] = $annot;
  844. } // *ANNOTATIONS*
  845. } // *ANNOTATIONS*
  846. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  847. if (!empty($properties))
  848. $this->mpdf->setCSS($properties, 'INLINE');
  849. // mPDF 6 Bidirectional formatting for inline elements
  850. $bdf = false;
  851. $bdf2 = '';
  852. $popd = '';
  853. // Get current direction
  854. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction'])) {
  855. $currdir = $this->mpdf->blk[$this->mpdf->blklvl]['direction'];
  856. } else {
  857. $currdir = 'ltr';
  858. }
  859. if ($this->mpdf->tableLevel && isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction'] == 'rtl') {
  860. $currdir = 'rtl';
  861. }
  862. if (isset($attr['DIR']) and $attr['DIR'] != '') {
  863. $currdir = strtolower($attr['DIR']);
  864. }
  865. if (isset($properties['DIRECTION'])) {
  866. $currdir = strtolower($properties['DIRECTION']);
  867. }
  868. // mPDF 6 bidi
  869. // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
  870. if ($tag == 'BDO') {
  871. if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
  872. $bdf = 0x202E;
  873. $popd = 'RLOPDF';
  874. } // U+202E RLO
  875. else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
  876. $bdf = 0x202D;
  877. $popd = 'LROPDF';
  878. } // U+202D LRO
  879. } else if ($tag == 'BDI') {
  880. if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
  881. $bdf = 0x2067;
  882. $popd = 'RLIPDI';
  883. } // U+2067 RLI
  884. else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
  885. $bdf = 0x2066;
  886. $popd = 'LRIPDI';
  887. } // U+2066 LRI
  888. else {
  889. $bdf = 0x2068;
  890. $popd = 'FSIPDI';
  891. } // U+2068 FSI
  892. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'bidi-override') {
  893. if ($currdir == 'rtl') {
  894. $bdf = 0x202E;
  895. $popd = 'RLOPDF';
  896. } // U+202E RLO
  897. else {
  898. $bdf = 0x202D;
  899. $popd = 'LROPDF';
  900. } // U+202D LRO
  901. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'embed') {
  902. if ($currdir == 'rtl') {
  903. $bdf = 0x202B;
  904. $popd = 'RLEPDF';
  905. } // U+202B RLE
  906. else {
  907. $bdf = 0x202A;
  908. $popd = 'LREPDF';
  909. } // U+202A LRE
  910. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate') {
  911. if ($currdir == 'rtl') {
  912. $bdf = 0x2067;
  913. $popd = 'RLIPDI';
  914. } // U+2067 RLI
  915. else {
  916. $bdf = 0x2066;
  917. $popd = 'LRIPDI';
  918. } // U+2066 LRI
  919. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate-override') {
  920. if ($currdir == 'rtl') {
  921. $bdf = 0x2067;
  922. $bdf2 = 0x202E;
  923. $popd = 'RLIRLOPDFPDI';
  924. } // U+2067 RLI // U+202E RLO
  925. else {
  926. $bdf = 0x2066;
  927. $bdf2 = 0x202D;
  928. $popd = 'LRILROPDFPDI';
  929. } // U+2066 LRI // U+202D LRO
  930. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
  931. $bdf = 0x2068;
  932. $popd = 'FSIPDI'; // U+2068 FSI
  933. } else {
  934. if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
  935. $bdf = 0x202B;
  936. $popd = 'RLEPDF';
  937. } // U+202B RLE
  938. else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
  939. $bdf = 0x202A;
  940. $popd = 'LREPDF';
  941. } // U+202A LRE
  942. }
  943. if ($bdf) {
  944. // mPDF 5.7.3 Inline tags
  945. if (!isset($this->mpdf->InlineBDF[$tag])) {
  946. $this->mpdf->InlineBDF[$tag] = array(array($popd, $this->mpdf->InlineBDFctr));
  947. } else {
  948. $this->mpdf->InlineBDF[$tag][] = array($popd, $this->mpdf->InlineBDFctr);
  949. }
  950. $this->mpdf->InlineBDFctr++;
  951. if ($bdf2) {
  952. $bdf2 = code2utf($bdf);
  953. }
  954. $this->mpdf->OTLdata = array();
  955. if ($this->mpdf->tableLevel) {
  956. $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
  957. } else {
  958. $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2);
  959. }
  960. $this->mpdf->biDirectional = true;
  961. }
  962. break;
  963. case 'A':
  964. if (isset($attr['NAME']) and $attr['NAME'] != '') {
  965. $e = '';
  966. /* -- BOOKMARKS -- */
  967. if ($this->mpdf->anchor2Bookmark) {
  968. $objattr = array();
  969. $objattr['CONTENT'] = htmlspecialchars_decode($attr['NAME'], ENT_QUOTES);
  970. $objattr['type'] = 'bookmark';
  971. if (isset($attr['LEVEL']) && $attr['LEVEL']) {
  972. $objattr['bklevel'] = $attr['LEVEL'];
  973. } else {
  974. $objattr['bklevel'] = 0;
  975. }
  976. $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  977. }
  978. /* -- END BOOKMARKS -- */
  979. if ($this->mpdf->tableLevel) { // *TABLES*
  980. $this->mpdf->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
  981. } // *TABLES*
  982. else { // *TABLES*
  983. $this->mpdf->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
  984. } // *TABLES*
  985. }
  986. if (isset($attr['HREF'])) {
  987. $this->mpdf->InlineProperties['A'] = $this->mpdf->saveInlineProperties();
  988. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  989. if (!empty($properties))
  990. $this->mpdf->setCSS($properties, 'INLINE');
  991. $this->mpdf->HREF = $attr['HREF']; // mPDF 5.7.4 URLs
  992. }
  993. break;
  994. case 'LEGEND':
  995. $this->mpdf->InlineProperties['LEGEND'] = $this->mpdf->saveInlineProperties();
  996. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  997. if (!empty($properties))
  998. $this->mpdf->setCSS($properties, 'INLINE');
  999. break;
  1000. case 'PROGRESS':
  1001. case 'METER':
  1002. $this->mpdf->inMeter = true;
  1003. if (isset($attr['MAX']) && $attr['MAX']) {
  1004. $max = $attr['MAX'];
  1005. } else {
  1006. $max = 1;
  1007. }
  1008. if (isset($attr['MIN']) && $attr['MIN'] && $tag == 'METER') {
  1009. $min = $attr['MIN'];
  1010. } else {
  1011. $min = 0;
  1012. }
  1013. if ($max < $min) {
  1014. $max = $min;
  1015. }
  1016. if (isset($attr['VALUE']) && ($attr['VALUE'] || $attr['VALUE'] === '0')) {
  1017. $value = $attr['VALUE'];
  1018. if ($value < $min) {
  1019. $value = $min;
  1020. } else if ($value > $max) {
  1021. $value = $max;
  1022. }
  1023. } else {
  1024. $value = '';
  1025. }
  1026. if (isset($attr['LOW']) && $attr['LOW']) {
  1027. $low = $attr['LOW'];
  1028. } else {
  1029. $low = $min;
  1030. }
  1031. if ($low < $min) {
  1032. $low = $min;
  1033. } else if ($low > $max) {
  1034. $low = $max;
  1035. }
  1036. if (isset($attr['HIGH']) && $attr['HIGH']) {
  1037. $high = $attr['HIGH'];
  1038. } else {
  1039. $high = $max;
  1040. }
  1041. if ($high < $low) {
  1042. $high = $low;
  1043. } else if ($high > $max) {
  1044. $high = $max;
  1045. }
  1046. if (isset($attr['OPTIMUM']) && $attr['OPTIMUM']) {
  1047. $optimum = $attr['OPTIMUM'];
  1048. } else {
  1049. $optimum = $min + (($max - $min) / 2);
  1050. }
  1051. if ($optimum < $min) {
  1052. $optimum = $min;
  1053. } else if ($optimum > $max) {
  1054. $optimum = $max;
  1055. }
  1056. if (isset($attr['TYPE']) && $attr['TYPE']) {
  1057. $type = $attr['TYPE'];
  1058. } else {
  1059. $type = '';
  1060. }
  1061. $objattr = array();
  1062. $objattr['margin_top'] = 0;
  1063. $objattr['margin_bottom'] = 0;
  1064. $objattr['margin_left'] = 0;
  1065. $objattr['margin_right'] = 0;
  1066. $objattr['padding_top'] = 0;
  1067. $objattr['padding_bottom'] = 0;
  1068. $objattr['padding_left'] = 0;
  1069. $objattr['padding_right'] = 0;
  1070. $objattr['width'] = 0;
  1071. $objattr['height'] = 0;
  1072. $objattr['border_top']['w'] = 0;
  1073. $objattr['border_bottom']['w'] = 0;
  1074. $objattr['border_left']['w'] = 0;
  1075. $objattr['border_right']['w'] = 0;
  1076. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  1077. if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
  1078. return;
  1079. }
  1080. $objattr['visibility'] = 'visible';
  1081. if (isset($properties['VISIBILITY'])) {
  1082. $v = strtolower($properties['VISIBILITY']);
  1083. if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
  1084. $objattr['visibility'] = $v;
  1085. }
  1086. }
  1087. if (isset($properties['MARGIN-TOP'])) {
  1088. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1089. }
  1090. if (isset($properties['MARGIN-BOTTOM'])) {
  1091. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1092. }
  1093. if (isset($properties['MARGIN-LEFT'])) {
  1094. $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1095. }
  1096. if (isset($properties['MARGIN-RIGHT'])) {
  1097. $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1098. }
  1099. if (isset($properties['PADDING-TOP'])) {
  1100. $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1101. }
  1102. if (isset($properties['PADDING-BOTTOM'])) {
  1103. $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1104. }
  1105. if (isset($properties['PADDING-LEFT'])) {
  1106. $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1107. }
  1108. if (isset($properties['PADDING-RIGHT'])) {
  1109. $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1110. }
  1111. if (isset($properties['BORDER-TOP'])) {
  1112. $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  1113. }
  1114. if (isset($properties['BORDER-BOTTOM'])) {
  1115. $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  1116. }
  1117. if (isset($properties['BORDER-LEFT'])) {
  1118. $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  1119. }
  1120. if (isset($properties['BORDER-RIGHT'])) {
  1121. $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  1122. }
  1123. if (isset($properties['VERTICAL-ALIGN'])) {
  1124. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  1125. }
  1126. $w = 0;
  1127. $h = 0;
  1128. if (isset($properties['WIDTH']))
  1129. $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1130. else if (isset($attr['WIDTH']))
  1131. $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1132. if (isset($properties['HEIGHT']))
  1133. $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1134. else if (isset($attr['HEIGHT']))
  1135. $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1136. if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
  1137. $objattr['opacity'] = $properties['OPACITY'];
  1138. }
  1139. if ($this->mpdf->HREF) {
  1140. if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
  1141. $href = $this->mpdf->HREF;
  1142. while (array_key_exists($href, $this->mpdf->internallink))
  1143. $href = "#" . $href;
  1144. $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
  1145. $objattr['link'] = $this->mpdf->internallink[$href];
  1146. } else {
  1147. $objattr['link'] = $this->mpdf->HREF;
  1148. }
  1149. }
  1150. $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
  1151. $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
  1152. // Image file
  1153. if (!class_exists('meter', false)) {
  1154. include(_MPDF_PATH . 'classes/meter.php');
  1155. }
  1156. $this->mpdf->meter = new meter();
  1157. $svg = $this->mpdf->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
  1158. //Save to local file
  1159. $srcpath = _MPDF_TEMP_PATH . '_tempSVG' . uniqid(rand(1, 100000), true) . '_' . strtolower($tag) . '.svg';
  1160. file_put_contents($srcpath, $svg);
  1161. $orig_srcpath = $srcpath;
  1162. $this->mpdf->GetFullPath($srcpath);
  1163. $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath);
  1164. if (!$info) {
  1165. $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
  1166. if ($info) {
  1167. $srcpath = $this->mpdf->noImageFile;
  1168. $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
  1169. $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
  1170. }
  1171. }
  1172. if (!$info)
  1173. break;
  1174. $objattr['file'] = $srcpath;
  1175. //Default width and height calculation if needed
  1176. if ($w == 0 and $h == 0) {
  1177. // SVG units are pixels
  1178. $w = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['w']) / _MPDFK;
  1179. $h = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['h']) / _MPDFK;
  1180. }
  1181. // IF WIDTH OR HEIGHT SPECIFIED
  1182. if ($w == 0)
  1183. $w = abs($h * $info['w'] / $info['h']);
  1184. if ($h == 0)
  1185. $h = abs($w * $info['h'] / $info['w']);
  1186. // Resize to maximum dimensions of page
  1187. $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
  1188. $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1);
  1189. if ($this->mpdf->fullImageHeight) {
  1190. $maxHeight = $this->mpdf->fullImageHeight;
  1191. }
  1192. if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
  1193. $w = $maxWidth - $extrawidth;
  1194. $h = abs($w * $info['h'] / $info['w']);
  1195. }
  1196. if ($h + $extraheight > $maxHeight) {
  1197. $h = $maxHeight - $extraheight;
  1198. $w = abs($h * $info['w'] / $info['h']);
  1199. }
  1200. $objattr['type'] = 'image';
  1201. $objattr['itype'] = $info['type'];
  1202. $objattr['orig_h'] = $info['h'];
  1203. $objattr['orig_w'] = $info['w'];
  1204. $objattr['wmf_x'] = $info['x'];
  1205. $objattr['wmf_y'] = $info['y'];
  1206. $objattr['height'] = $h + $extraheight;
  1207. $objattr['width'] = $w + $extrawidth;
  1208. $objattr['image_height'] = $h;
  1209. $objattr['image_width'] = $w;
  1210. $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  1211. $properties = array();
  1212. if ($this->mpdf->tableLevel) {
  1213. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  1214. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
  1215. } else {
  1216. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  1217. }
  1218. break;
  1219. case 'BR':
  1220. // Added mPDF 3.0 Float DIV - CLEAR
  1221. if (isset($attr['STYLE'])) {
  1222. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']);
  1223. if (isset($properties['CLEAR'])) {
  1224. $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl);
  1225. } // *CSS-FLOAT*
  1226. }
  1227. // mPDF 6 bidi
  1228. // Inline
  1229. // If unicode-bidi set, any embedding levels, isolates, or overrides started by the inline box are closed at the br and reopened on the other side
  1230. $blockpre = '';
  1231. $blockpost = '';
  1232. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
  1233. $blockpre = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
  1234. $blockpost = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
  1235. }
  1236. // Inline
  1237. // If unicode-bidi set, any embedding levels, isolates, or overrides started by the inline box are closed at the br and reopened on the other side
  1238. $inlinepre = '';
  1239. $inlinepost = '';
  1240. $iBDF = array();
  1241. if (count($this->mpdf->InlineBDF)) {
  1242. foreach ($this->mpdf->InlineBDF AS $k => $ib) {
  1243. foreach ($ib AS $ib2) {
  1244. $iBDF[$ib2[1]] = $ib2[0];
  1245. }
  1246. }
  1247. if (count($iBDF)) {
  1248. ksort($iBDF);
  1249. for ($i = count($iBDF) - 1; $i >= 0; $i--) {
  1250. $inlinepre .= $this->mpdf->_setBidiCodes('end', $iBDF[$i]);
  1251. }
  1252. for ($i = 0; $i < count($iBDF); $i++) {
  1253. $inlinepost .= $this->mpdf->_setBidiCodes('start', $iBDF[$i]);
  1254. }
  1255. }
  1256. }
  1257. /* -- TABLES -- */
  1258. if ($this->mpdf->tableLevel) {
  1259. if ($this->mpdf->blockjustfinished) {
  1260. $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
  1261. }
  1262. $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
  1263. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  1264. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  1265. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  1266. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  1267. }
  1268. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
  1269. } else {
  1270. /* -- END TABLES -- */
  1271. if (count($this->mpdf->textbuffer)) {
  1272. $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = preg_replace('/ $/', '', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]);
  1273. if (!empty($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18])) {
  1274. $this->mpdf->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false, true);
  1275. } // *OTL*
  1276. }
  1277. $this->mpdf->_saveTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
  1278. } // *TABLES*
  1279. $this->mpdf->ignorefollowingspaces = true;
  1280. $this->mpdf->blockjustfinished = false;
  1281. $this->mpdf->linebreakjustfinished = true;
  1282. break;
  1283. // *********** BLOCKS ********************
  1284. case 'PRE':
  1285. $this->mpdf->ispre = true; // ADDED - Prevents left trim of textbuffer in printbuffer()
  1286. case 'DIV':
  1287. case 'FORM':
  1288. case 'CENTER':
  1289. case 'BLOCKQUOTE':
  1290. case 'ADDRESS':
  1291. case 'CAPTION':
  1292. case 'P':
  1293. case 'H1':
  1294. case 'H2':
  1295. case 'H3':
  1296. case 'H4':
  1297. case 'H5':
  1298. case 'H6':
  1299. case 'DL':
  1300. case 'DT':
  1301. case 'DD':
  1302. case 'UL': // mPDF 6 Lists
  1303. case 'OL': // mPDF 6
  1304. case 'LI': // mPDF 6
  1305. case 'FIELDSET':
  1306. case 'DETAILS':
  1307. case 'SUMMARY':
  1308. case 'ARTICLE':
  1309. case 'ASIDE':
  1310. case 'FIGURE':
  1311. case 'FIGCAPTION':
  1312. case 'FOOTER':
  1313. case 'HEADER':
  1314. case 'HGROUP':
  1315. case 'NAV':
  1316. case 'SECTION':
  1317. case 'MAIN':
  1318. // mPDF 6 Lists
  1319. $this->mpdf->lastoptionaltag = '';
  1320. // mPDF 6 bidi
  1321. // Block
  1322. // If unicode-bidi set on current clock, any embedding levels, isolates, or overrides are closed (not inherited)
  1323. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
  1324. $blockpost = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
  1325. if ($blockpost) {
  1326. $this->mpdf->OTLdata = array();
  1327. if ($this->mpdf->tableLevel) {
  1328. $this->mpdf->_saveCellTextBuffer($blockpost);
  1329. } else {
  1330. $this->mpdf->_saveTextBuffer($blockpost);
  1331. }
  1332. }
  1333. }
  1334. $p = $this->mpdf->cssmgr->PreviewBlockCSS($tag, $attr);
  1335. if (isset($p['DISPLAY']) && strtolower($p['DISPLAY']) == 'none') {
  1336. $this->mpdf->blklvl++;
  1337. $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true;
  1338. $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6
  1339. return;
  1340. }
  1341. if ($tag == 'CAPTION') {
  1342. // position is written in AdjstHTML
  1343. if (isset($attr['POSITION']) && strtolower($attr['POSITION']) == 'bottom') {
  1344. $divpos = 'B';
  1345. } else {
  1346. $divpos = 'T';
  1347. }
  1348. if (isset($attr['ALIGN']) && strtolower($attr['ALIGN']) == 'bottom') {
  1349. $cappos = 'B';
  1350. } else if (isset($p['CAPTION-SIDE']) && strtolower($p['CAPTION-SIDE']) == 'bottom') {
  1351. $cappos = 'B';
  1352. } else {
  1353. $cappos = 'T';
  1354. }
  1355. if (isset($attr['ALIGN'])) {
  1356. unset($attr['ALIGN']);
  1357. }
  1358. if ($cappos != $divpos) {
  1359. $this->mpdf->blklvl++;
  1360. $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true;
  1361. $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6
  1362. return;
  1363. }
  1364. }
  1365. /* -- FORMS -- */
  1366. if ($tag == 'FORM') {
  1367. if (isset($attr['METHOD']) && strtolower($attr['METHOD']) == 'get') {
  1368. $this->mpdf->mpdfform->formMethod = 'GET';
  1369. } else {
  1370. $this->mpdf->mpdfform->formMethod = 'POST';
  1371. }
  1372. if (isset($attr['ACTION'])) {
  1373. $this->mpdf->mpdfform->formAction = $attr['ACTION'];
  1374. } else {
  1375. $this->mpdf->mpdfform->formAction = '';
  1376. }
  1377. }
  1378. /* -- END FORMS -- */
  1379. /* -- CSS-POSITION -- */
  1380. if ((isset($p['POSITION']) && (strtolower($p['POSITION']) == 'fixed' || strtolower($p['POSITION']) == 'absolute')) && $this->mpdf->blklvl == 0) {
  1381. if ($this->mpdf->inFixedPosBlock) {
  1382. throw new MpdfException("Cannot nest block with position:fixed or position:absolute");
  1383. }
  1384. $this->mpdf->inFixedPosBlock = true;
  1385. return;
  1386. }
  1387. /* -- END CSS-POSITION -- */
  1388. // Start Block
  1389. $this->mpdf->ignorefollowingspaces = true;
  1390. if ($this->mpdf->blockjustfinished && !count($this->mpdf->textbuffer) && $this->mpdf->y != $this->mpdf->tMargin && $this->mpdf->collapseBlockMargins) {
  1391. $lastbottommargin = $this->mpdf->lastblockbottommargin;
  1392. } else {
  1393. $lastbottommargin = 0;
  1394. }
  1395. $this->mpdf->lastblockbottommargin = 0;
  1396. $this->mpdf->blockjustfinished = false;
  1397. $this->mpdf->InlineBDF = array(); // mPDF 6
  1398. $this->mpdf->InlineBDFctr = 0; // mPDF 6
  1399. $this->mpdf->InlineProperties = array();
  1400. $this->mpdf->divbegin = true;
  1401. $this->mpdf->linebreakjustfinished = false;
  1402. /* -- TABLES -- */
  1403. if ($this->mpdf->tableLevel) {
  1404. // If already something on the line
  1405. if ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] > 0 && !$this->mpdf->nestedtablejustfinished) {
  1406. $this->mpdf->_saveCellTextBuffer("\n");
  1407. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  1408. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  1409. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  1410. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  1411. }
  1412. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
  1413. }
  1414. // Cannot set block properties inside table - use Bold to indicate h1-h6
  1415. if ($tag == 'CENTER' && $this->mpdf->tdbegin) {
  1416. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'] = $align['center'];
  1417. }
  1418. $this->mpdf->InlineProperties['BLOCKINTABLE'] = $this->mpdf->saveInlineProperties();
  1419. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  1420. if (!empty($properties))
  1421. $this->mpdf->setCSS($properties, 'INLINE');
  1422. // mPDF 6 Lists
  1423. if ($tag == 'UL' || $tag == 'OL') {
  1424. $this->mpdf->listlvl++;
  1425. if (isset($attr['START'])) {
  1426. $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1;
  1427. } else {
  1428. $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
  1429. }
  1430. $this->mpdf->listitem = array();
  1431. if ($tag == 'OL')
  1432. $this->mpdf->listtype[$this->mpdf->listlvl] = 'decimal';
  1433. else if ($tag == 'UL') {
  1434. if ($this->mpdf->listlvl % 3 == 1)
  1435. $this->mpdf->listtype[$this->mpdf->listlvl] = 'disc';
  1436. elseif ($this->mpdf->listlvl % 3 == 2)
  1437. $this->mpdf->listtype[$this->mpdf->listlvl] = 'circle';
  1438. else
  1439. $this->mpdf->listtype[$this->mpdf->listlvl] = 'square';
  1440. }
  1441. }
  1442. // mPDF 6 Lists - in Tables
  1443. if ($tag == 'LI') {
  1444. if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)</p><li>Content</li><p>Paragraph1</p>(...)
  1445. $this->mpdf->listlvl++; // first depth level
  1446. $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
  1447. }
  1448. $this->mpdf->listcounter[$this->mpdf->listlvl] ++;
  1449. $this->mpdf->listitem = array();
  1450. //if in table - output here as a tabletextbuffer
  1451. //position:inside OR position:outside (always output in table as position:inside)
  1452. switch ($this->mpdf->listtype[$this->mpdf->listlvl]) {
  1453. case 'upper-alpha':
  1454. case 'upper-latin':
  1455. case 'A':
  1456. $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix;
  1457. break;
  1458. case 'lower-alpha':
  1459. case 'lower-latin':
  1460. case 'a':
  1461. $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix;
  1462. break;
  1463. case 'upper-roman':
  1464. case 'I':
  1465. $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix;
  1466. break;
  1467. case 'lower-roman':
  1468. case 'i':
  1469. $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix;
  1470. break;
  1471. case 'decimal':
  1472. case '1':
  1473. $blt = $this->mpdf->listcounter[$this->mpdf->listlvl] . $this->mpdf->list_number_suffix;
  1474. break;
  1475. default:
  1476. if ($this->mpdf->listlvl % 3 == 1 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 8226)) {
  1477. $blt = "\xe2\x80\xa2";
  1478. } // &#8226;
  1479. else if ($this->mpdf->listlvl % 3 == 2 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9900)) {
  1480. $blt = "\xe2\x9a\xac";
  1481. } // &#9900;
  1482. else if ($this->mpdf->listlvl % 3 == 0 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9642)) {
  1483. $blt = "\xe2\x96\xaa";
  1484. } // &#9642;
  1485. else {
  1486. $blt = '-';
  1487. }
  1488. break;
  1489. }
  1490. // change to &nbsp; spaces
  1491. if ($this->mpdf->usingCoreFont) {
  1492. $ls = str_repeat(chr(160) . chr(160), ($this->mpdf->listlvl - 1) * 2) . $blt . ' ';
  1493. } else {
  1494. $ls = str_repeat("\xc2\xa0\xc2\xa0", ($this->mpdf->listlvl - 1) * 2) . $blt . ' ';
  1495. }
  1496. $this->mpdf->_saveCellTextBuffer($ls);
  1497. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $this->mpdf->GetStringWidth($ls);
  1498. }
  1499. break;
  1500. }
  1501. /* -- END TABLES -- */
  1502. if ($this->mpdf->lastblocklevelchange == 1) {
  1503. $blockstate = 1;
  1504. } // Top margins/padding only
  1505. else if ($this->mpdf->lastblocklevelchange < 1) {
  1506. $blockstate = 0;
  1507. } // NO margins/padding
  1508. $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
  1509. $this->mpdf->textbuffer = array();
  1510. $save_blklvl = $this->mpdf->blklvl;
  1511. $save_blk = $this->mpdf->blk;
  1512. $this->mpdf->Reset();
  1513. $pagesel = '';
  1514. /* -- CSS-PAGE -- */
  1515. if (isset($p['PAGE'])) {
  1516. $pagesel = $p['PAGE'];
  1517. } // mPDF 6 (uses $p - preview of properties so blklvl can be incremented after page-break)
  1518. /* -- END CSS-PAGE -- */
  1519. // If page-box has changed AND/OR PAGE-BREAK-BEFORE
  1520. // mPDF 6 (uses $p - preview of properties so blklvl can be imcremented after page-break)
  1521. if (!$this->mpdf->tableLevel && (($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) || (isset($p['PAGE-BREAK-BEFORE']) && $p['PAGE-BREAK-BEFORE']))) {
  1522. // mPDF 6 pagebreaktype
  1523. $startpage = $this->mpdf->page;
  1524. $pagebreaktype = $this->mpdf->defaultPagebreakType;
  1525. $this->mpdf->lastblocklevelchange = -1;
  1526. if ($this->mpdf->ColActive) {
  1527. $pagebreaktype = 'cloneall';
  1528. }
  1529. if ($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) {
  1530. $pagebreaktype = 'cloneall';
  1531. }
  1532. $this->mpdf->_preForcedPagebreak($pagebreaktype);
  1533. if (isset($p['PAGE-BREAK-BEFORE'])) {
  1534. if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'RIGHT') {
  1535. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
  1536. } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'LEFT') {
  1537. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
  1538. } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'ALWAYS') {
  1539. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
  1540. } else if ($this->mpdf->page_box['current'] != $pagesel) {
  1541. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
  1542. } // *CSS-PAGE*
  1543. }
  1544. /* -- CSS-PAGE -- */
  1545. // Must Add new page if changed page properties
  1546. else if (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current']) {
  1547. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
  1548. }
  1549. /* -- END CSS-PAGE -- */
  1550. // mPDF 6 pagebreaktype
  1551. $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
  1552. }
  1553. // mPDF 6 pagebreaktype - moved after pagebreak
  1554. $this->mpdf->blklvl++;
  1555. $currblk = & $this->mpdf->blk[$this->mpdf->blklvl];
  1556. $this->mpdf->initialiseBlock($currblk);
  1557. $prevblk = & $this->mpdf->blk[$this->mpdf->blklvl - 1];
  1558. $currblk['tag'] = $tag;
  1559. $currblk['attr'] = $attr;
  1560. $properties = $this->mpdf->cssmgr->MergeCSS('BLOCK', $tag, $attr); // mPDF 6 - moved to after page-break-before
  1561. // mPDF 6 page-break-inside:avoid
  1562. if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) { // avoid re-iterating using PAGEBREAKAVOIDCHECKED; set in CloseTag
  1563. $currblk['keep_block_together'] = 1;
  1564. $currblk['array_i'] = $ihtml; // mPDF 6
  1565. $this->mpdf->kt_y00 = $this->mpdf->y;
  1566. $this->mpdf->kt_p00 = $this->mpdf->page;
  1567. $this->mpdf->keep_block_together = 1;
  1568. }
  1569. if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) {
  1570. $currblk['lastbottommargin'] = $lastbottommargin;
  1571. }
  1572. if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) {
  1573. $v = intval($properties['Z-INDEX']);
  1574. if ($v > 0) {
  1575. $currblk['z-index'] = $v;
  1576. $this->mpdf->BeginLayer($v);
  1577. }
  1578. }
  1579. // mPDF 6 Lists
  1580. // List-type set by attribute
  1581. if ($tag == 'OL' || $tag == 'UL' || $tag == 'LI') {
  1582. if (isset($attr['TYPE']) && $attr['TYPE']) {
  1583. $listtype = $attr['TYPE'];
  1584. switch ($listtype) {
  1585. case 'A':
  1586. $listtype = 'upper-latin';
  1587. break;
  1588. case 'a':
  1589. $listtype = 'lower-latin';
  1590. break;
  1591. case 'I':
  1592. $listtype = 'upper-roman';
  1593. break;
  1594. case 'i':
  1595. $listtype = 'lower-roman';
  1596. break;
  1597. case '1':
  1598. $listtype = 'decimal';
  1599. break;
  1600. }
  1601. $currblk['list_style_type'] = $listtype;
  1602. }
  1603. }
  1604. $this->mpdf->setCSS($properties, 'BLOCK', $tag); //name(id/class/style) found in the CSS array!
  1605. $currblk['InlineProperties'] = $this->mpdf->saveInlineProperties();
  1606. if (isset($properties['VISIBILITY'])) {
  1607. $v = strtolower($properties['VISIBILITY']);
  1608. if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible' && !$this->mpdf->tableLevel) {
  1609. $currblk['visibility'] = $v;
  1610. $this->mpdf->SetVisibility($v);
  1611. }
  1612. }
  1613. // mPDF 6
  1614. if (isset($attr['ALIGN']) && $attr['ALIGN']) {
  1615. $currblk['block-align'] = $align[strtolower($attr['ALIGN'])];
  1616. }
  1617. if (isset($properties['HEIGHT'])) {
  1618. $currblk['css_set_height'] = $this->mpdf->ConvertSize($properties['HEIGHT'], ($this->mpdf->h - $this->mpdf->tMargin - $this->mpdf->bMargin), $this->mpdf->FontSize, false);
  1619. if (($currblk['css_set_height'] + $this->mpdf->y) > $this->mpdf->PageBreakTrigger && $this->mpdf->y > $this->mpdf->tMargin + 5 && $currblk['css_set_height'] < ($this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin))) {
  1620. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  1621. }
  1622. } else {
  1623. $currblk['css_set_height'] = false;
  1624. }
  1625. // Added mPDF 3.0 Float DIV
  1626. if (isset($prevblk['blockContext'])) {
  1627. $currblk['blockContext'] = $prevblk['blockContext'];
  1628. } // *CSS-FLOAT*
  1629. if (isset($properties['CLEAR'])) {
  1630. $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl - 1);
  1631. } // *CSS-FLOAT*
  1632. $container_w = $prevblk['inner_width'];
  1633. $bdr = $currblk['border_right']['w'];
  1634. $bdl = $currblk['border_left']['w'];
  1635. $pdr = $currblk['padding_right'];
  1636. $pdl = $currblk['padding_left'];
  1637. if (isset($currblk['css_set_width'])) {
  1638. $setwidth = $currblk['css_set_width'];
  1639. } else {
  1640. $setwidth = 0;
  1641. }
  1642. /* -- CSS-FLOAT -- */
  1643. if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'RIGHT' && !$this->mpdf->ColActive) {
  1644. // Cancel Keep-Block-together
  1645. $currblk['keep_block_together'] = false;
  1646. $this->mpdf->kt_y00 = '';
  1647. $this->mpdf->keep_block_together = 0;
  1648. $this->mpdf->blockContext++;
  1649. $currblk['blockContext'] = $this->mpdf->blockContext;
  1650. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1651. // DIV is too narrow for text to fit!
  1652. $maxw = $container_w - $l_width - $r_width;
  1653. if (($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
  1654. // Too narrow to fit - try to move down past L or R float
  1655. if ($l_max < $r_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1656. $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
  1657. } else if ($r_max < $l_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1658. $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
  1659. } else {
  1660. $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
  1661. }
  1662. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1663. }
  1664. if ($r_exists) {
  1665. $currblk['margin_right'] += $r_width;
  1666. }
  1667. $currblk['float'] = 'R';
  1668. $currblk['float_start_y'] = $this->mpdf->y;
  1669. if ($currblk['css_set_width']) {
  1670. $currblk['margin_left'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
  1671. $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
  1672. } else {
  1673. // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width
  1674. // and do borders and backgrounds - For now - just set to maximum width left
  1675. if ($l_exists) {
  1676. $currblk['margin_left'] += $l_width;
  1677. }
  1678. $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr);
  1679. $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
  1680. }
  1681. } else if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'LEFT' && !$this->mpdf->ColActive) {
  1682. // Cancel Keep-Block-together
  1683. $currblk['keep_block_together'] = false;
  1684. $this->mpdf->kt_y00 = '';
  1685. $this->mpdf->keep_block_together = 0;
  1686. $this->mpdf->blockContext++;
  1687. $currblk['blockContext'] = $this->mpdf->blockContext;
  1688. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1689. // DIV is too narrow for text to fit!
  1690. $maxw = $container_w - $l_width - $r_width;
  1691. if (($setwidth + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
  1692. // Too narrow to fit - try to move down past L or R float
  1693. if ($l_max < $r_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1694. $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
  1695. } else if ($r_max < $l_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1696. $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
  1697. } else {
  1698. $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
  1699. }
  1700. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1701. }
  1702. if ($l_exists) {
  1703. $currblk['margin_left'] += $l_width;
  1704. }
  1705. $currblk['float'] = 'L';
  1706. $currblk['float_start_y'] = $this->mpdf->y;
  1707. if ($setwidth) {
  1708. $currblk['margin_right'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
  1709. $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
  1710. } else {
  1711. // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width
  1712. // and do borders and backgrounds - For now - just set to maximum width left
  1713. if ($r_exists) {
  1714. $currblk['margin_right'] += $r_width;
  1715. }
  1716. $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr);
  1717. $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
  1718. }
  1719. } else {
  1720. // Don't allow overlap - if floats present - adjust padding to avoid overlap with Floats
  1721. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1722. $maxw = $container_w - $l_width - $r_width;
  1723. if (($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
  1724. // Too narrow to fit - try to move down past L or R float
  1725. if ($l_max < $r_max && ($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1726. $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
  1727. } else if ($r_max < $l_max && ($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
  1728. $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
  1729. } else {
  1730. $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
  1731. }
  1732. list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
  1733. }
  1734. if ($r_exists) {
  1735. $currblk['padding_right'] = max(($r_width - $currblk['margin_right'] - $bdr), $pdr);
  1736. }
  1737. if ($l_exists) {
  1738. $currblk['padding_left'] = max(($l_width - $currblk['margin_left'] - $bdl), $pdl);
  1739. }
  1740. }
  1741. /* -- END CSS-FLOAT -- */
  1742. /* -- BORDER-RADIUS -- */
  1743. // Automatically increase padding if required for border-radius
  1744. if ($this->mpdf->autoPadding && !$this->mpdf->ColActive) {
  1745. if ($currblk['border_radius_TL_H'] > $currblk['padding_left'] && $currblk['border_radius_TL_V'] > $currblk['padding_top']) {
  1746. if ($currblk['border_radius_TL_H'] > $currblk['border_radius_TL_V']) {
  1747. $this->mpdf->_borderPadding($currblk['border_radius_TL_H'], $currblk['border_radius_TL_V'], $currblk['padding_left'], $currblk['padding_top']);
  1748. } else {
  1749. $this->mpdf->_borderPadding($currblk['border_radius_TL_V'], $currblk['border_radius_TL_H'], $currblk['padding_top'], $currblk['padding_left']);
  1750. }
  1751. }
  1752. if ($currblk['border_radius_TR_H'] > $currblk['padding_right'] && $currblk['border_radius_TR_V'] > $currblk['padding_top']) {
  1753. if ($currblk['border_radius_TR_H'] > $currblk['border_radius_TR_V']) {
  1754. $this->mpdf->_borderPadding($currblk['border_radius_TR_H'], $currblk['border_radius_TR_V'], $currblk['padding_right'], $currblk['padding_top']);
  1755. } else {
  1756. $this->mpdf->_borderPadding($currblk['border_radius_TR_V'], $currblk['border_radius_TR_H'], $currblk['padding_top'], $currblk['padding_right']);
  1757. }
  1758. }
  1759. if ($currblk['border_radius_BL_H'] > $currblk['padding_left'] && $currblk['border_radius_BL_V'] > $currblk['padding_bottom']) {
  1760. if ($currblk['border_radius_BL_H'] > $currblk['border_radius_BL_V']) {
  1761. $this->mpdf->_borderPadding($currblk['border_radius_BL_H'], $currblk['border_radius_BL_V'], $currblk['padding_left'], $currblk['padding_bottom']);
  1762. } else {
  1763. $this->mpdf->_borderPadding($currblk['border_radius_BL_V'], $currblk['border_radius_BL_H'], $currblk['padding_bottom'], $currblk['padding_left']);
  1764. }
  1765. }
  1766. if ($currblk['border_radius_BR_H'] > $currblk['padding_right'] && $currblk['border_radius_BR_V'] > $currblk['padding_bottom']) {
  1767. if ($currblk['border_radius_BR_H'] > $currblk['border_radius_BR_V']) {
  1768. $this->mpdf->_borderPadding($currblk['border_radius_BR_H'], $currblk['border_radius_BR_V'], $currblk['padding_right'], $currblk['padding_bottom']);
  1769. } else {
  1770. $this->mpdf->_borderPadding($currblk['border_radius_BR_V'], $currblk['border_radius_BR_H'], $currblk['padding_bottom'], $currblk['padding_right']);
  1771. }
  1772. }
  1773. }
  1774. /* -- END BORDER-RADIUS -- */
  1775. // Hanging indent - if negative indent: ensure padding is >= indent
  1776. if (!isset($currblk['text_indent'])) {
  1777. $currblk['text_indent'] = null;
  1778. }
  1779. if (!isset($currblk['inner_width'])) {
  1780. $currblk['inner_width'] = null;
  1781. }
  1782. $cbti = $this->mpdf->ConvertSize($currblk['text_indent'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  1783. if ($cbti < 0) {
  1784. $hangind = -($cbti);
  1785. if (isset($currblk['direction']) && $currblk['direction'] == 'rtl') { // *OTL*
  1786. $currblk['padding_right'] = max($currblk['padding_right'], $hangind); // *OTL*
  1787. } // *OTL*
  1788. else { // *OTL*
  1789. $currblk['padding_left'] = max($currblk['padding_left'], $hangind);
  1790. } // *OTL*
  1791. }
  1792. if (isset($currblk['css_set_width'])) {
  1793. if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
  1794. // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width)
  1795. $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
  1796. if ($anyextra > 0) {
  1797. $currblk['margin_left'] = $currblk['margin_right'] = $anyextra / 2;
  1798. } else {
  1799. $currblk['margin_left'] = $currblk['margin_right'] = 0;
  1800. }
  1801. } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
  1802. // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
  1803. $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']);
  1804. if ($currblk['margin_left'] < 0) {
  1805. $currblk['margin_left'] = 0;
  1806. }
  1807. } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
  1808. // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
  1809. $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
  1810. if ($currblk['margin_right'] < 0) {
  1811. $currblk['margin_right'] = 0;
  1812. }
  1813. } else {
  1814. if ($currblk['direction'] == 'rtl') { // *OTL*
  1815. // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
  1816. $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']); // *OTL*
  1817. if ($currblk['margin_left'] < 0) { // *OTL*
  1818. $currblk['margin_left'] = 0; // *OTL*
  1819. } // *OTL*
  1820. } // *OTL*
  1821. else { // *OTL*
  1822. // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
  1823. $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
  1824. if ($currblk['margin_right'] < 0) {
  1825. $currblk['margin_right'] = 0;
  1826. }
  1827. } // *OTL*
  1828. }
  1829. }
  1830. $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left'];
  1831. $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right'];
  1832. $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']);
  1833. $currblk['inner_width'] = $currblk['width'] - ($currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
  1834. // Check DIV is not now too narrow to fit text
  1835. $mw = 2 * $this->mpdf->GetCharWidth('W', false);
  1836. if ($currblk['inner_width'] < $mw) {
  1837. $currblk['padding_left'] = 0;
  1838. $currblk['padding_right'] = 0;
  1839. $currblk['border_left']['w'] = 0.2;
  1840. $currblk['border_right']['w'] = 0.2;
  1841. $currblk['margin_left'] = 0;
  1842. $currblk['margin_right'] = 0;
  1843. $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left'];
  1844. $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right'];
  1845. $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']);
  1846. $currblk['inner_width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
  1847. // if ($currblk['inner_width'] < $mw) { throw new MpdfException("DIV is too narrow for text to fit!"); }
  1848. }
  1849. $this->mpdf->x = $this->mpdf->lMargin + $currblk['outer_left_margin'];
  1850. /* -- BACKGROUNDS -- */
  1851. if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) {
  1852. $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
  1853. if ($ret) {
  1854. $currblk['background-image'] = $ret;
  1855. }
  1856. }
  1857. /* -- END BACKGROUNDS -- */
  1858. /* -- TABLES -- */
  1859. if ($this->mpdf->use_kwt && isset($attr['KEEP-WITH-TABLE']) && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) {
  1860. $this->mpdf->kwt = true;
  1861. $this->mpdf->kwt_y0 = $this->mpdf->y;
  1862. //$this->mpdf->kwt_x0 = $this->mpdf->x;
  1863. $this->mpdf->kwt_x0 = $this->mpdf->lMargin; // mPDF 6
  1864. $this->mpdf->kwt_height = 0;
  1865. $this->mpdf->kwt_buffer = array();
  1866. $this->mpdf->kwt_Links = array();
  1867. $this->mpdf->kwt_Annots = array();
  1868. $this->mpdf->kwt_moved = false;
  1869. $this->mpdf->kwt_saved = false;
  1870. $this->mpdf->kwt_Reference = array();
  1871. $this->mpdf->kwt_BMoutlines = array();
  1872. $this->mpdf->kwt_toc = array();
  1873. } else {
  1874. /* -- END TABLES -- */
  1875. $this->mpdf->kwt = false;
  1876. } // *TABLES*
  1877. //Save x,y coords in case we need to print borders...
  1878. $currblk['y0'] = $this->mpdf->y;
  1879. $currblk['initial_y0'] = $this->mpdf->y; // mPDF 6
  1880. $currblk['x0'] = $this->mpdf->x;
  1881. $currblk['initial_x0'] = $this->mpdf->x; // mPDF 6
  1882. $currblk['initial_startpage'] = $this->mpdf->page;
  1883. $currblk['startpage'] = $this->mpdf->page; // mPDF 6
  1884. $this->mpdf->oldy = $this->mpdf->y;
  1885. $this->mpdf->lastblocklevelchange = 1;
  1886. // mPDF 6 Lists
  1887. if ($tag == 'OL' || $tag == 'UL') {
  1888. $this->mpdf->listlvl++;
  1889. if (isset($attr['START']) && $attr['START']) {
  1890. $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1;
  1891. } else {
  1892. $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
  1893. }
  1894. $this->mpdf->listitem = array();
  1895. // List-type
  1896. if (!isset($currblk['list_style_type']) || !$currblk['list_style_type']) {
  1897. if ($tag == 'OL')
  1898. $currblk['list_style_type'] = 'decimal';
  1899. else if ($tag == 'UL') {
  1900. if ($this->mpdf->listlvl % 3 == 1)
  1901. $currblk['list_style_type'] = 'disc';
  1902. elseif ($this->mpdf->listlvl % 3 == 2)
  1903. $currblk['list_style_type'] = 'circle';
  1904. else
  1905. $currblk['list_style_type'] = 'square';
  1906. }
  1907. }
  1908. // List-image
  1909. if (!isset($currblk['list_style_image']) || !$currblk['list_style_image']) {
  1910. $currblk['list_style_image'] = 'none';
  1911. }
  1912. // List-position
  1913. if (!isset($currblk['list_style_position']) || !$currblk['list_style_position']) {
  1914. $currblk['list_style_position'] = 'outside';
  1915. }
  1916. // Default indentation using padding
  1917. if (strtolower($this->mpdf->list_auto_mode) == 'mpdf' && isset($currblk['list_style_position']) && $currblk['list_style_position'] == 'outside' && isset($currblk['list_style_image']) && $currblk['list_style_image'] == 'none' && (!isset($currblk['list_style_type']) || !preg_match('/U\+([a-fA-F0-9]+)/i', $currblk['list_style_type']))) {
  1918. $autopadding = $this->mpdf->_getListMarkerWidth($currblk, $ahtml, $ihtml);
  1919. if ($this->mpdf->listlvl > 1 || $this->mpdf->list_indent_first_level) {
  1920. $autopadding += $this->mpdf->ConvertSize($this->mpdf->list_indent_default_mpdf, $currblk['inner_width'], $this->mpdf->FontSize, false);
  1921. }
  1922. // autopadding value is applied to left or right according
  1923. // to dir of block. Once a CSS value is set for padding it overrides this default value.
  1924. if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') {
  1925. $currblk['padding_right'] = $autopadding;
  1926. } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') {
  1927. $currblk['padding_left'] = $autopadding;
  1928. }
  1929. } else {
  1930. // Initial default value is set by $this->mpdf->list_indent_default in config.php; this value is applied to left or right according
  1931. // to dir of block. Once a CSS value is set for padding it overrides this default value.
  1932. if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') {
  1933. $currblk['padding_right'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false);
  1934. } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') {
  1935. $currblk['padding_left'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false);
  1936. }
  1937. }
  1938. }
  1939. // mPDF 6 Lists
  1940. if ($tag == 'LI') {
  1941. if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)</p><li>Content</li><p>Paragraph1</p>(...)
  1942. $this->mpdf->listlvl++; // first depth level
  1943. $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
  1944. }
  1945. $this->mpdf->listcounter[$this->mpdf->listlvl] ++;
  1946. $this->mpdf->listitem = array();
  1947. // Listitem-type
  1948. $this->mpdf->_setListMarker($currblk['list_style_type'], $currblk['list_style_image'], $currblk['list_style_position']);
  1949. }
  1950. // mPDF 6 Bidirectional formatting for block elements
  1951. $bdf = false;
  1952. $bdf2 = '';
  1953. $popd = '';
  1954. // Get current direction
  1955. if (isset($currblk['direction'])) {
  1956. $currdir = $currblk['direction'];
  1957. } else {
  1958. $currdir = 'ltr';
  1959. }
  1960. if (isset($attr['DIR']) and $attr['DIR'] != '') {
  1961. $currdir = strtolower($attr['DIR']);
  1962. }
  1963. if (isset($properties['DIRECTION'])) {
  1964. $currdir = strtolower($properties['DIRECTION']);
  1965. }
  1966. // mPDF 6 bidi
  1967. // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
  1968. if (isset($properties ['UNICODE-BIDI']) && (strtolower($properties ['UNICODE-BIDI']) == 'bidi-override' || strtolower($properties ['UNICODE-BIDI']) == 'isolate-override')) {
  1969. if ($currdir == 'rtl') {
  1970. $bdf = 0x202E;
  1971. $popd = 'RLOPDF';
  1972. } // U+202E RLO
  1973. else {
  1974. $bdf = 0x202D;
  1975. $popd = 'LROPDF';
  1976. } // U+202D LRO
  1977. } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
  1978. $bdf = 0x2068;
  1979. $popd = 'FSIPDI'; // U+2068 FSI
  1980. }
  1981. if ($bdf) {
  1982. if ($bdf2) {
  1983. $bdf2 = code2utf($bdf);
  1984. }
  1985. $this->mpdf->OTLdata = array();
  1986. if ($this->mpdf->tableLevel) {
  1987. $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
  1988. } else {
  1989. $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2);
  1990. }
  1991. $this->mpdf->biDirectional = true;
  1992. $currblk['bidicode'] = $popd;
  1993. }
  1994. break;
  1995. case 'HR':
  1996. // Added mPDF 3.0 Float DIV - CLEAR
  1997. if (isset($attr['STYLE'])) {
  1998. $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']);
  1999. if (isset($properties['CLEAR'])) {
  2000. $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl);
  2001. } // *CSS-FLOAT*
  2002. }
  2003. $this->mpdf->ignorefollowingspaces = true;
  2004. $objattr = array();
  2005. $objattr['margin_top'] = 0;
  2006. $objattr['margin_bottom'] = 0;
  2007. $objattr['margin_left'] = 0;
  2008. $objattr['margin_right'] = 0;
  2009. $objattr['width'] = 0;
  2010. $objattr['height'] = 0;
  2011. $objattr['border_top']['w'] = 0;
  2012. $objattr['border_bottom']['w'] = 0;
  2013. $objattr['border_left']['w'] = 0;
  2014. $objattr['border_right']['w'] = 0;
  2015. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2016. if (isset($properties['MARGIN-TOP'])) {
  2017. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2018. }
  2019. if (isset($properties['MARGIN-BOTTOM'])) {
  2020. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2021. }
  2022. if (isset($properties['WIDTH'])) {
  2023. $objattr['width'] = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2024. } else if (isset($attr['WIDTH']) && $attr['WIDTH'] != '')
  2025. $objattr['width'] = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2026. if (isset($properties['TEXT-ALIGN'])) {
  2027. $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])];
  2028. } else if (isset($attr['ALIGN']) && $attr['ALIGN'] != '')
  2029. $objattr['align'] = $align[strtolower($attr['ALIGN'])];
  2030. if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
  2031. $objattr['align'] = 'R';
  2032. }
  2033. if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
  2034. $objattr['align'] = 'L';
  2035. if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
  2036. $objattr['align'] = 'C';
  2037. }
  2038. }
  2039. if (isset($properties['COLOR'])) {
  2040. $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
  2041. } else if (isset($attr['COLOR']) && $attr['COLOR'] != '')
  2042. $objattr['color'] = $this->mpdf->ConvertColor($attr['COLOR']);
  2043. if (isset($properties['HEIGHT'])) {
  2044. $objattr['linewidth'] = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2045. }
  2046. /* -- TABLES -- */
  2047. if ($this->mpdf->tableLevel) {
  2048. $objattr['W-PERCENT'] = 100;
  2049. if (isset($properties['WIDTH']) && stristr($properties['WIDTH'], '%')) {
  2050. $properties['WIDTH'] += 0; //make "90%" become simply "90"
  2051. $objattr['W-PERCENT'] = $properties['WIDTH'];
  2052. }
  2053. if (isset($attr['WIDTH']) && stristr($attr['WIDTH'], '%')) {
  2054. $attr['WIDTH'] += 0; //make "90%" become simply "90"
  2055. $objattr['W-PERCENT'] = $attr['WIDTH'];
  2056. }
  2057. }
  2058. /* -- END TABLES -- */
  2059. $objattr['type'] = 'hr';
  2060. $objattr['height'] = $objattr['linewidth'] + $objattr['margin_top'] + $objattr['margin_bottom'];
  2061. $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  2062. // Clear properties - tidy up
  2063. $properties = array();
  2064. /* -- TABLES -- */
  2065. // Output it to buffers
  2066. if ($this->mpdf->tableLevel) {
  2067. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  2068. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  2069. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  2070. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  2071. }
  2072. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
  2073. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  2074. } else {
  2075. /* -- END TABLES -- */
  2076. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  2077. } // *TABLES*
  2078. break;
  2079. /* -- BARCODES -- */
  2080. case 'BARCODE':
  2081. $this->mpdf->ignorefollowingspaces = false;
  2082. if (isset($attr['CODE']) && $attr['CODE']) {
  2083. $objattr = array();
  2084. $objattr['margin_top'] = 0;
  2085. $objattr['margin_bottom'] = 0;
  2086. $objattr['margin_left'] = 0;
  2087. $objattr['margin_right'] = 0;
  2088. $objattr['padding_top'] = 0;
  2089. $objattr['padding_bottom'] = 0;
  2090. $objattr['padding_left'] = 0;
  2091. $objattr['padding_right'] = 0;
  2092. $objattr['width'] = 0;
  2093. $objattr['height'] = 0;
  2094. $objattr['border_top']['w'] = 0;
  2095. $objattr['border_bottom']['w'] = 0;
  2096. $objattr['border_left']['w'] = 0;
  2097. $objattr['border_right']['w'] = 0;
  2098. $objattr['code'] = $attr['CODE'];
  2099. if (isset($attr['TYPE'])) {
  2100. $objattr['btype'] = trim(strtoupper($attr['TYPE']));
  2101. } else {
  2102. $objattr['btype'] = 'EAN13';
  2103. } // default
  2104. if (preg_match('/^(EAN13|ISBN|ISSN|EAN8|UPCA|UPCE)P([25])$/', $objattr['btype'], $m)) {
  2105. $objattr['btype'] = $m[1];
  2106. $objattr['bsupp'] = $m[2];
  2107. if (preg_match('/^(\S+)\s+(.*)$/', $objattr['code'], $mm)) {
  2108. $objattr['code'] = $mm[1];
  2109. $objattr['bsupp_code'] = $mm[2];
  2110. }
  2111. } else {
  2112. $objattr['bsupp'] = 0;
  2113. }
  2114. if (isset($attr['TEXT']) && $attr['TEXT'] == 1) {
  2115. $objattr['showtext'] = 1;
  2116. } else {
  2117. $objattr['showtext'] = 0;
  2118. }
  2119. if (isset($attr['SIZE']) && $attr['SIZE'] > 0) {
  2120. $objattr['bsize'] = $attr['SIZE'];
  2121. } else {
  2122. $objattr['bsize'] = 1;
  2123. }
  2124. if (isset($attr['HEIGHT']) && $attr['HEIGHT'] > 0) {
  2125. $objattr['bheight'] = $attr['HEIGHT'];
  2126. } else {
  2127. $objattr['bheight'] = 1;
  2128. }
  2129. if (isset($attr['PR']) && $attr['PR'] > 0) {
  2130. $objattr['pr_ratio'] = $attr['PR'];
  2131. } else {
  2132. $objattr['pr_ratio'] = '';
  2133. }
  2134. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2135. if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
  2136. return;
  2137. }
  2138. if (isset($properties['MARGIN-TOP'])) {
  2139. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2140. }
  2141. if (isset($properties['MARGIN-BOTTOM'])) {
  2142. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2143. }
  2144. if (isset($properties['MARGIN-LEFT'])) {
  2145. $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2146. }
  2147. if (isset($properties['MARGIN-RIGHT'])) {
  2148. $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2149. }
  2150. if (isset($properties['PADDING-TOP'])) {
  2151. $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2152. }
  2153. if (isset($properties['PADDING-BOTTOM'])) {
  2154. $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2155. }
  2156. if (isset($properties['PADDING-LEFT'])) {
  2157. $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2158. }
  2159. if (isset($properties['PADDING-RIGHT'])) {
  2160. $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2161. }
  2162. if (isset($properties['BORDER-TOP'])) {
  2163. $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  2164. }
  2165. if (isset($properties['BORDER-BOTTOM'])) {
  2166. $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  2167. }
  2168. if (isset($properties['BORDER-LEFT'])) {
  2169. $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  2170. }
  2171. if (isset($properties['BORDER-RIGHT'])) {
  2172. $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  2173. }
  2174. if (isset($properties['VERTICAL-ALIGN'])) {
  2175. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  2176. }
  2177. if (isset($properties['COLOR']) && $properties['COLOR'] != '') {
  2178. $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
  2179. } else {
  2180. $objattr['color'] = false;
  2181. }
  2182. if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
  2183. $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
  2184. } else {
  2185. $objattr['bgcolor'] = false;
  2186. }
  2187. if (!class_exists('PDFBarcode', false)) {
  2188. include(_MPDF_PATH . 'classes/barcode.php');
  2189. }
  2190. $this->mpdf->barcode = new PDFBarcode();
  2191. if ($objattr['btype'] == 'EAN13' || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN' || $objattr['btype'] == 'UPCA' || $objattr['btype'] == 'UPCE' || $objattr['btype'] == 'EAN8') {
  2192. $code = preg_replace('/\-/', '', $objattr['code']);
  2193. if ($objattr['btype'] == 'ISSN' || $objattr['btype'] == 'ISBN') {
  2194. $arrcode = $this->mpdf->barcode->getBarcodeArray($code, 'EAN13');
  2195. } else {
  2196. $arrcode = $this->mpdf->barcode->getBarcodeArray($code, $objattr['btype']);
  2197. }
  2198. if ($arrcode === false) {
  2199. throw new MpdfException('Error in barcode string.');
  2200. }
  2201. if ($objattr['bsupp'] == 2 || $objattr['bsupp'] == 5) { // EAN-2 or -5 Supplement
  2202. $supparrcode = $this->mpdf->barcode->getBarcodeArray($objattr['bsupp_code'], 'EAN' . $objattr['bsupp']);
  2203. $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR'] + $supparrcode["maxw"] + $supparrcode['sepM']) * $arrcode['nom-X'] * $objattr['bsize'];
  2204. } else {
  2205. $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize'];
  2206. }
  2207. $h = $arrcode['nom-H'] * $objattr['bsize'] * $objattr['bheight'];
  2208. // Add height for ISBN string + margin from top of bars
  2209. if (($objattr['showtext'] && $objattr['btype'] == 'EAN13') || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN') {
  2210. $tisbnm = 1.5 * $objattr['bsize']; // Top margin between TOP TEXT (isbn - if shown) & bars
  2211. $isbn_fontsize = 2.1 * $objattr['bsize'];
  2212. $h += $isbn_fontsize + $tisbnm;
  2213. }
  2214. }
  2215. // QR-code
  2216. else if ($objattr['btype'] == 'QR') {
  2217. $w = $h = $objattr['bsize'] * 25; // Factor of 25mm (default)
  2218. $objattr['errorlevel'] = 'L';
  2219. if (isset($attr['ERROR'])) {
  2220. $objattr['errorlevel'] = $attr['ERROR'];
  2221. }
  2222. } else if ($objattr['btype'] == 'IMB' || $objattr['btype'] == 'RM4SCC' || $objattr['btype'] == 'KIX' || $objattr['btype'] == 'POSTNET' || $objattr['btype'] == 'PLANET') {
  2223. $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype']);
  2224. if ($arrcode === false) {
  2225. throw new MpdfException('Error in barcode string.');
  2226. }
  2227. $w = ($arrcode["maxw"] * $arrcode['nom-X'] * $objattr['bsize']) + $arrcode['quietL'] + $arrcode['quietR'];
  2228. $h = ($arrcode['nom-H'] * $objattr['bsize']) + (2 * $arrcode['quietTB']);
  2229. } else if (in_array($objattr['btype'], array('C128A', 'C128B', 'C128C', 'EAN128A', 'EAN128B', 'EAN128C', 'C39', 'C39+', 'C39E', 'C39E+', 'S25', 'S25+', 'I25', 'I25+', 'I25B', 'I25B+', 'C93', 'MSI', 'MSI+', 'CODABAR', 'CODE11'))) {
  2230. $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype'], $objattr['pr_ratio']);
  2231. if ($arrcode === false) {
  2232. throw new MpdfException('Error in barcode string.');
  2233. }
  2234. $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize'];
  2235. $h = ((2 * $arrcode['lightTB'] * $arrcode['nom-X']) + $arrcode['nom-H']) * $objattr['bsize'] * $objattr['bheight'];
  2236. } else {
  2237. break;
  2238. }
  2239. $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
  2240. $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
  2241. $objattr['type'] = 'barcode';
  2242. $objattr['height'] = $h + $extraheight;
  2243. $objattr['width'] = $w + $extrawidth;
  2244. $objattr['barcode_height'] = $h;
  2245. $objattr['barcode_width'] = $w;
  2246. /* -- CSS-IMAGE-FLOAT -- */
  2247. if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) {
  2248. if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
  2249. $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1);
  2250. }
  2251. }
  2252. /* -- END CSS-IMAGE-FLOAT -- */
  2253. $e = "\xbb\xa4\xactype=barcode,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  2254. // Clear properties - tidy up
  2255. $properties = array();
  2256. /* -- TABLES -- */
  2257. // Output it to buffers
  2258. if ($this->mpdf->tableLevel) {
  2259. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  2260. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
  2261. } else {
  2262. /* -- END TABLES -- */
  2263. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  2264. } // *TABLES*
  2265. }
  2266. break;
  2267. /* -- END BARCODES -- */
  2268. // *********** FORM ELEMENTS ********************
  2269. /* -- FORMS -- */
  2270. case 'SELECT':
  2271. $this->mpdf->lastoptionaltag = ''; // Save current HTML specified optional endtag
  2272. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  2273. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2274. if (isset($properties['FONT-FAMILY'])) {
  2275. $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
  2276. }
  2277. if (isset($properties['FONT-SIZE'])) {
  2278. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
  2279. $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
  2280. }
  2281. if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
  2282. $this->mpdf->selectoption['SPELLCHECK'] = true;
  2283. }
  2284. if (isset($properties['COLOR'])) {
  2285. $this->mpdf->selectoption['COLOR'] = $this->mpdf->ConvertColor($properties['COLOR']);
  2286. }
  2287. $this->mpdf->specialcontent = "type=select";
  2288. if (isset($attr['DISABLED'])) {
  2289. $this->mpdf->selectoption['DISABLED'] = $attr['DISABLED'];
  2290. }
  2291. if (isset($attr['READONLY'])) {
  2292. $this->mpdf->selectoption['READONLY'] = $attr['READONLY'];
  2293. }
  2294. if (isset($attr['REQUIRED'])) {
  2295. $this->mpdf->selectoption['REQUIRED'] = $attr['REQUIRED'];
  2296. }
  2297. if (isset($attr['EDITABLE'])) {
  2298. $this->mpdf->selectoption['EDITABLE'] = $attr['EDITABLE'];
  2299. }
  2300. if (isset($attr['TITLE'])) {
  2301. $this->mpdf->selectoption['TITLE'] = $attr['TITLE'];
  2302. }
  2303. if (isset($attr['MULTIPLE'])) {
  2304. $this->mpdf->selectoption['MULTIPLE'] = $attr['MULTIPLE'];
  2305. }
  2306. if (isset($attr['SIZE']) && $attr['SIZE'] > 1) {
  2307. $this->mpdf->selectoption['SIZE'] = $attr['SIZE'];
  2308. }
  2309. if ($this->mpdf->useActiveForms) {
  2310. if (isset($attr['NAME'])) {
  2311. $this->mpdf->selectoption['NAME'] = $attr['NAME'];
  2312. }
  2313. if (isset($attr['ONCHANGE'])) {
  2314. $this->mpdf->selectoption['ONCHANGE'] = $attr['ONCHANGE'];
  2315. }
  2316. }
  2317. $properties = array();
  2318. break;
  2319. case 'OPTION':
  2320. $this->mpdf->lastoptionaltag = '';
  2321. $this->mpdf->selectoption['ACTIVE'] = true;
  2322. $this->mpdf->selectoption['currentSEL'] = false;
  2323. if (empty($this->mpdf->selectoption)) {
  2324. $this->mpdf->selectoption['MAXWIDTH'] = '';
  2325. $this->mpdf->selectoption['SELECTED'] = '';
  2326. }
  2327. if (isset($attr['SELECTED'])) {
  2328. $this->mpdf->selectoption['SELECTED'] = '';
  2329. $this->mpdf->selectoption['currentSEL'] = true;
  2330. }
  2331. if (isset($attr['VALUE'])) {
  2332. $attr['VALUE'] = strcode2utf($attr['VALUE']);
  2333. $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']);
  2334. if ($this->mpdf->onlyCoreFonts)
  2335. $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8');
  2336. }
  2337. $this->mpdf->selectoption['currentVAL'] = $attr['VALUE'];
  2338. break;
  2339. case 'TEXTAREA':
  2340. $objattr = array();
  2341. $objattr['margin_top'] = 0;
  2342. $objattr['margin_bottom'] = 0;
  2343. $objattr['margin_left'] = 0;
  2344. $objattr['margin_right'] = 0;
  2345. $objattr['width'] = 0;
  2346. $objattr['height'] = 0;
  2347. $objattr['border_top']['w'] = 0;
  2348. $objattr['border_bottom']['w'] = 0;
  2349. $objattr['border_left']['w'] = 0;
  2350. $objattr['border_right']['w'] = 0;
  2351. if (isset($attr['DISABLED'])) {
  2352. $objattr['disabled'] = true;
  2353. }
  2354. if (isset($attr['READONLY'])) {
  2355. $objattr['readonly'] = true;
  2356. }
  2357. if (isset($attr['REQUIRED'])) {
  2358. $objattr['required'] = true;
  2359. }
  2360. if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
  2361. $objattr['spellcheck'] = true;
  2362. }
  2363. if (isset($attr['TITLE'])) {
  2364. $objattr['title'] = $attr['TITLE'];
  2365. if ($this->mpdf->onlyCoreFonts)
  2366. $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8');
  2367. }
  2368. if ($this->mpdf->useActiveForms) {
  2369. if (isset($attr['NAME'])) {
  2370. $objattr['fieldname'] = $attr['NAME'];
  2371. }
  2372. $this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] = 0;
  2373. $this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] = 0;
  2374. if (isset($attr['ONCALCULATE'])) {
  2375. $objattr['onCalculate'] = $attr['ONCALCULATE'];
  2376. } else if (isset($attr['ONCHANGE'])) {
  2377. $objattr['onCalculate'] = $attr['ONCHANGE'];
  2378. }
  2379. if (isset($attr['ONVALIDATE'])) {
  2380. $objattr['onValidate'] = $attr['ONVALIDATE'];
  2381. }
  2382. if (isset($attr['ONKEYSTROKE'])) {
  2383. $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
  2384. }
  2385. if (isset($attr['ONFORMAT'])) {
  2386. $objattr['onFormat'] = $attr['ONFORMAT'];
  2387. }
  2388. }
  2389. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  2390. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2391. if (isset($properties['FONT-FAMILY'])) {
  2392. $this->mpdf->SetFont($properties['FONT-FAMILY'], '', 0, false);
  2393. }
  2394. if (isset($properties['FONT-SIZE'])) {
  2395. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
  2396. $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
  2397. }
  2398. if (isset($properties['COLOR'])) {
  2399. $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
  2400. }
  2401. $objattr['fontfamily'] = $this->mpdf->FontFamily;
  2402. $objattr['fontsize'] = $this->mpdf->FontSizePt;
  2403. if ($this->mpdf->useActiveForms) {
  2404. if (isset($properties['TEXT-ALIGN'])) {
  2405. $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])];
  2406. } else if (isset($attr['ALIGN'])) {
  2407. $objattr['text_align'] = $align[strtolower($attr['ALIGN'])];
  2408. }
  2409. if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW']) == 'hidden') {
  2410. $objattr['donotscroll'] = true;
  2411. }
  2412. if (isset($properties['BORDER-TOP-COLOR'])) {
  2413. $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']);
  2414. }
  2415. if (isset($properties['BACKGROUND-COLOR'])) {
  2416. $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
  2417. }
  2418. }
  2419. $this->mpdf->SetLineHeight('', $this->mpdf->mpdfform->textarea_lineheight);
  2420. $w = 0;
  2421. $h = 0;
  2422. if (isset($properties['WIDTH']))
  2423. $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2424. if (isset($properties['HEIGHT']))
  2425. $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2426. if (isset($properties['VERTICAL-ALIGN'])) {
  2427. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  2428. }
  2429. $colsize = 20; //HTML default value
  2430. $rowsize = 2; //HTML default value
  2431. if (isset($attr['COLS']))
  2432. $colsize = intval($attr['COLS']);
  2433. if (isset($attr['ROWS']))
  2434. $rowsize = intval($attr['ROWS']);
  2435. $charsize = $this->mpdf->GetCharWidth('w', false);
  2436. if ($w) {
  2437. $colsize = round(($w - ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) - ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2)) / $charsize);
  2438. }
  2439. if ($h) {
  2440. $rowsize = round(($h - ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] * 2) - ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] * 2)) / $this->mpdf->lineheight);
  2441. }
  2442. $objattr['type'] = 'textarea';
  2443. $objattr['width'] = ($colsize * $charsize) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2);
  2444. $objattr['height'] = ($rowsize * $this->mpdf->lineheight) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] * 2);
  2445. $objattr['rows'] = $rowsize;
  2446. $objattr['cols'] = $colsize;
  2447. $this->mpdf->specialcontent = serialize($objattr);
  2448. if ($this->mpdf->tableLevel) { // *TABLES*
  2449. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; // *TABLES*
  2450. } // *TABLES*
  2451. // Clear properties - tidy up
  2452. $properties = array();
  2453. break;
  2454. // *********** FORM - INPUT ********************
  2455. case 'INPUT':
  2456. $this->mpdf->ignorefollowingspaces = false;
  2457. if (!isset($attr['TYPE']))
  2458. $attr['TYPE'] == 'TEXT';
  2459. $objattr = array();
  2460. $objattr['margin_top'] = 0;
  2461. $objattr['margin_bottom'] = 0;
  2462. $objattr['margin_left'] = 0;
  2463. $objattr['margin_right'] = 0;
  2464. $objattr['width'] = 0;
  2465. $objattr['height'] = 0;
  2466. $objattr['border_top']['w'] = 0;
  2467. $objattr['border_bottom']['w'] = 0;
  2468. $objattr['border_left']['w'] = 0;
  2469. $objattr['border_right']['w'] = 0;
  2470. $objattr['type'] = 'input';
  2471. if (isset($attr['DISABLED'])) {
  2472. $objattr['disabled'] = true;
  2473. }
  2474. if (isset($attr['READONLY'])) {
  2475. $objattr['readonly'] = true;
  2476. }
  2477. if (isset($attr['REQUIRED'])) {
  2478. $objattr['required'] = true;
  2479. }
  2480. if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
  2481. $objattr['spellcheck'] = true;
  2482. }
  2483. if (isset($attr['TITLE'])) {
  2484. $objattr['title'] = $attr['TITLE'];
  2485. } else if (isset($attr['ALT'])) {
  2486. $objattr['title'] = $attr['ALT'];
  2487. } else
  2488. $objattr['title'] = '';
  2489. $objattr['title'] = strcode2utf($objattr['title']);
  2490. $objattr['title'] = $this->mpdf->lesser_entity_decode($objattr['title']);
  2491. if ($this->mpdf->onlyCoreFonts)
  2492. $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8');
  2493. if ($this->mpdf->useActiveForms) {
  2494. if (isset($attr['NAME'])) {
  2495. $objattr['fieldname'] = $attr['NAME'];
  2496. }
  2497. }
  2498. if (isset($attr['VALUE'])) {
  2499. $attr['VALUE'] = strcode2utf($attr['VALUE']);
  2500. $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']);
  2501. if ($this->mpdf->onlyCoreFonts)
  2502. $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8');
  2503. $objattr['value'] = $attr['VALUE'];
  2504. }
  2505. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  2506. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2507. $objattr['vertical-align'] = '';
  2508. if (isset($properties['FONT-FAMILY'])) {
  2509. $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
  2510. }
  2511. if (isset($properties['FONT-SIZE'])) {
  2512. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK));
  2513. $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
  2514. }
  2515. if (isset($properties['COLOR'])) {
  2516. $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
  2517. }
  2518. $objattr['fontfamily'] = $this->mpdf->FontFamily;
  2519. $objattr['fontsize'] = $this->mpdf->FontSizePt;
  2520. if ($this->mpdf->useActiveForms) {
  2521. if (isset($attr['ALIGN'])) {
  2522. $objattr['text_align'] = $align[strtolower($attr['ALIGN'])];
  2523. } else if (isset($properties['TEXT-ALIGN'])) {
  2524. $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])];
  2525. }
  2526. if (isset($properties['BORDER-TOP-COLOR'])) {
  2527. $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']);
  2528. }
  2529. if (isset($properties['BACKGROUND-COLOR'])) {
  2530. $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
  2531. }
  2532. }
  2533. $type = '';
  2534. $texto = '';
  2535. $height = $this->mpdf->FontSize;
  2536. $width = 0;
  2537. $spacesize = $this->mpdf->GetCharWidth(' ', false);
  2538. $w = 0;
  2539. if (isset($properties['WIDTH']))
  2540. $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2541. if ($properties['VERTICAL-ALIGN']) {
  2542. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  2543. }
  2544. switch (strtoupper($attr['TYPE'])) {
  2545. case 'HIDDEN':
  2546. $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
  2547. if ($this->mpdf->useActiveForms) {
  2548. $this->mpdf->mpdfform->SetFormText(0, 0, $objattr['fieldname'], $objattr['value'], $objattr['value'], '', 0, '', true);
  2549. }
  2550. if ($this->mpdf->InlineProperties[$tag]) {
  2551. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  2552. }
  2553. unset($this->mpdf->InlineProperties[$tag]);
  2554. break 2;
  2555. case 'CHECKBOX': //Draw Checkbox
  2556. $type = 'CHECKBOX';
  2557. if (isset($attr['CHECKED'])) {
  2558. $objattr['checked'] = true;
  2559. } else {
  2560. $objattr['checked'] = false;
  2561. }
  2562. $width = $this->mpdf->FontSize;
  2563. $height = $this->mpdf->FontSize;
  2564. break;
  2565. case 'RADIO': //Draw Radio button
  2566. $type = 'RADIO';
  2567. if (isset($attr['CHECKED']))
  2568. $objattr['checked'] = true;
  2569. $width = $this->mpdf->FontSize;
  2570. $height = $this->mpdf->FontSize;
  2571. break;
  2572. /* -- IMAGES-CORE -- */
  2573. case 'IMAGE': // Draw an Image button
  2574. if (isset($attr['SRC'])) {
  2575. $type = 'IMAGE';
  2576. $srcpath = $attr['SRC'];
  2577. $orig_srcpath = $attr['ORIG_SRC'];
  2578. // VSPACE and HSPACE converted to margins in MergeCSS
  2579. if (isset($properties['MARGIN-TOP'])) {
  2580. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2581. }
  2582. if (isset($properties['MARGIN-BOTTOM'])) {
  2583. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2584. }
  2585. if (isset($properties['MARGIN-LEFT'])) {
  2586. $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2587. }
  2588. if (isset($properties['MARGIN-RIGHT'])) {
  2589. $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2590. }
  2591. if (isset($properties['BORDER-TOP'])) {
  2592. $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  2593. }
  2594. if (isset($properties['BORDER-BOTTOM'])) {
  2595. $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  2596. }
  2597. if (isset($properties['BORDER-LEFT'])) {
  2598. $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  2599. }
  2600. if (isset($properties['BORDER-RIGHT'])) {
  2601. $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  2602. }
  2603. $objattr['padding_top'] = 0;
  2604. $objattr['padding_bottom'] = 0;
  2605. $objattr['padding_left'] = 0;
  2606. $objattr['padding_right'] = 0;
  2607. if (isset($properties['VERTICAL-ALIGN'])) {
  2608. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  2609. }
  2610. $w = 0;
  2611. $h = 0;
  2612. if (isset($properties['WIDTH']))
  2613. $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2614. if (isset($properties['HEIGHT']))
  2615. $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2616. $extraheight = $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
  2617. $extrawidth = $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
  2618. // Image file
  2619. $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath);
  2620. if (!$info) {
  2621. $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
  2622. if ($info) {
  2623. $srcpath = $this->mpdf->noImageFile;
  2624. $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
  2625. $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
  2626. }
  2627. }
  2628. if (!$info)
  2629. break;
  2630. if ($info['cs'] == 'Indexed') {
  2631. $objattr['Indexed'] = true;
  2632. }
  2633. $objattr['file'] = $srcpath;
  2634. //Default width and height calculation if needed
  2635. if ($w == 0 and $h == 0) {
  2636. /* -- IMAGES-WMF -- */
  2637. if ($info['type'] == 'wmf') {
  2638. // WMF units are twips (1/20pt)
  2639. // divide by 20 to get points
  2640. // divide by k to get user units
  2641. $w = abs($info['w']) / (20 * _MPDFK);
  2642. $h = abs($info['h']) / (20 * _MPDFK);
  2643. } else
  2644. /* -- END IMAGES-WMF -- */
  2645. if ($info['type'] == 'svg') {
  2646. // SVG units are pixels
  2647. $w = abs($info['w']) / _MPDFK;
  2648. $h = abs($info['h']) / _MPDFK;
  2649. } else {
  2650. //Put image at default image dpi
  2651. $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
  2652. $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
  2653. }
  2654. if (isset($properties['IMAGE-RESOLUTION'])) {
  2655. if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) {
  2656. $w *= $this->mpdf->img_dpi / $info['set-dpi'];
  2657. $h *= $this->mpdf->img_dpi / $info['set-dpi'];
  2658. } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
  2659. $dpi = $m[1];
  2660. if ($dpi > 0) {
  2661. $w *= $this->mpdf->img_dpi / $dpi;
  2662. $h *= $this->mpdf->img_dpi / $dpi;
  2663. }
  2664. }
  2665. }
  2666. }
  2667. // IF WIDTH OR HEIGHT SPECIFIED
  2668. if ($w == 0)
  2669. $w = $h * $info['w'] / $info['h'];
  2670. if ($h == 0)
  2671. $h = $w * $info['h'] / $info['w'];
  2672. // Resize to maximum dimensions of page
  2673. $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
  2674. $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 10);
  2675. if ($this->mpdf->fullImageHeight) {
  2676. $maxHeight = $this->mpdf->fullImageHeight;
  2677. }
  2678. if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
  2679. $w = $maxWidth - $extrawidth;
  2680. $h = $w * $info['h'] / $info['w'];
  2681. }
  2682. if ($h + $extraheight > $maxHeight) {
  2683. $h = $maxHeight - $extraheight;
  2684. $w = $h * $info['w'] / $info['h'];
  2685. }
  2686. $height = $h + $extraheight;
  2687. $width = $w + $extrawidth;
  2688. $objattr['type'] = 'image';
  2689. $objattr['itype'] = $info['type'];
  2690. $objattr['orig_h'] = $info['h'];
  2691. $objattr['orig_w'] = $info['w'];
  2692. /* -- IMAGES-WMF -- */
  2693. if ($info['type'] == 'wmf') {
  2694. $objattr['wmf_x'] = $info['x'];
  2695. $objattr['wmf_y'] = $info['y'];
  2696. } else
  2697. /* -- END IMAGES-WMF -- */
  2698. if ($info['type'] == 'svg') {
  2699. $objattr['wmf_x'] = $info['x'];
  2700. $objattr['wmf_y'] = $info['y'];
  2701. }
  2702. $objattr['height'] = $h + $extraheight;
  2703. $objattr['width'] = $w + $extrawidth;
  2704. $objattr['image_height'] = $h;
  2705. $objattr['image_width'] = $w;
  2706. $objattr['ID'] = $info['i'];
  2707. $texto = 'X';
  2708. if ($this->mpdf->useActiveForms) {
  2709. if (isset($attr['ONCLICK'])) {
  2710. $objattr['onClick'] = $attr['ONCLICK'];
  2711. }
  2712. $objattr['type'] = 'input';
  2713. $type = 'IMAGE';
  2714. }
  2715. break;
  2716. }
  2717. /* -- END IMAGES-CORE -- */
  2718. case 'BUTTON': // Draw a button
  2719. case 'SUBMIT':
  2720. case 'RESET':
  2721. $type = strtoupper($attr['TYPE']);
  2722. if ($type == 'IMAGE') {
  2723. $type = 'BUTTON';
  2724. } // src path not found
  2725. if (isset($attr['NOPRINT'])) {
  2726. $objattr['noprint'] = true;
  2727. }
  2728. if (!isset($attr['VALUE'])) {
  2729. $objattr['value'] = ucfirst(strtolower($type));
  2730. }
  2731. $texto = " " . $objattr['value'] . " ";
  2732. $width = $this->mpdf->GetStringWidth($texto) + ($this->mpdf->mpdfform->form_element_spacing['button']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['button']['inner']['h'] * 2);
  2733. $height = $this->mpdf->FontSize + ($this->mpdf->mpdfform->form_element_spacing['button']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['button']['inner']['v'] * 2);
  2734. if ($this->mpdf->useActiveForms) {
  2735. if (isset($attr['ONCLICK'])) {
  2736. $objattr['onClick'] = $attr['ONCLICK'];
  2737. }
  2738. }
  2739. break;
  2740. case 'PASSWORD':
  2741. case 'TEXT':
  2742. default:
  2743. if ($type == '') {
  2744. $type = 'TEXT';
  2745. }
  2746. if (strtoupper($attr['TYPE']) == 'PASSWORD') {
  2747. $type = 'PASSWORD';
  2748. }
  2749. if (isset($attr['VALUE'])) {
  2750. if ($type == 'PASSWORD') {
  2751. $num_stars = mb_strlen($attr['VALUE'], $this->mpdf->mb_enc);
  2752. $texto = str_repeat('*', $num_stars);
  2753. } else {
  2754. $texto = $attr['VALUE'];
  2755. }
  2756. }
  2757. $xw = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['h'] * 2);
  2758. $xh = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['v'] * 2);
  2759. if ($w) {
  2760. $width = $w + $xw;
  2761. } else {
  2762. $width = (20 * $spacesize) + $xw;
  2763. } // Default width in chars
  2764. if (isset($attr['SIZE']) and ctype_digit($attr['SIZE']))
  2765. $width = ($attr['SIZE'] * $spacesize) + $xw;
  2766. $height = $this->mpdf->FontSize + $xh;
  2767. if (isset($attr['MAXLENGTH']) and ctype_digit($attr['MAXLENGTH']))
  2768. $objattr['maxlength'] = $attr['MAXLENGTH'];
  2769. if ($this->mpdf->useActiveForms) {
  2770. if (isset($attr['ONCALCULATE'])) {
  2771. $objattr['onCalculate'] = $attr['ONCALCULATE'];
  2772. } else if (isset($attr['ONCHANGE'])) {
  2773. $objattr['onCalculate'] = $attr['ONCHANGE'];
  2774. }
  2775. if (isset($attr['ONVALIDATE'])) {
  2776. $objattr['onValidate'] = $attr['ONVALIDATE'];
  2777. }
  2778. if (isset($attr['ONKEYSTROKE'])) {
  2779. $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
  2780. }
  2781. if (isset($attr['ONFORMAT'])) {
  2782. $objattr['onFormat'] = $attr['ONFORMAT'];
  2783. }
  2784. }
  2785. break;
  2786. }
  2787. $objattr['subtype'] = $type;
  2788. $objattr['text'] = $texto;
  2789. $objattr['width'] = $width;
  2790. $objattr['height'] = $height;
  2791. $e = "\xbb\xa4\xactype=input,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  2792. // Clear properties - tidy up
  2793. $properties = array();
  2794. /* -- TABLES -- */
  2795. // Output it to buffers
  2796. if ($this->mpdf->tableLevel) {
  2797. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  2798. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
  2799. } else {
  2800. /* -- END TABLES -- */
  2801. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  2802. } // *TABLES*
  2803. if ($this->mpdf->InlineProperties[$tag]) {
  2804. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  2805. }
  2806. unset($this->mpdf->InlineProperties[$tag]);
  2807. break; // END of INPUT
  2808. /* -- END FORMS -- */
  2809. // *********** GRAPH ********************
  2810. case 'JPGRAPH':
  2811. if (!$this->mpdf->useGraphs) {
  2812. break;
  2813. }
  2814. if ($attr['TABLE']) {
  2815. $gid = strtoupper($attr['TABLE']);
  2816. } else {
  2817. $gid = '0';
  2818. }
  2819. if (!is_array($this->mpdf->graphs[$gid]) || count($this->mpdf->graphs[$gid]) == 0) {
  2820. break;
  2821. }
  2822. $this->mpdf->ignorefollowingspaces = false;
  2823. include_once(_MPDF_PATH . 'graph.php');
  2824. $this->mpdf->graphs[$gid]['attr'] = $attr;
  2825. if (isset($this->mpdf->graphs[$gid]['attr']['WIDTH']) && $this->mpdf->graphs[$gid]['attr']['WIDTH']) {
  2826. $this->mpdf->graphs[$gid]['attr']['cWIDTH'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2827. } // mm
  2828. if (isset($this->mpdf->graphs[$gid]['attr']['HEIGHT']) && $this->mpdf->graphs[$gid]['attr']['HEIGHT']) {
  2829. $this->mpdf->graphs[$gid]['attr']['cHEIGHT'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2830. }
  2831. $graph_img = print_graph($this->mpdf->graphs[$gid], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  2832. if ($graph_img) {
  2833. if (isset($attr['ROTATE'])) {
  2834. if ($attr['ROTATE'] == 90 || $attr['ROTATE'] == -90) {
  2835. $tmpw = $graph_img['w'];
  2836. $graph_img['w'] = $graph_img['h'];
  2837. $graph_img['h'] = $tmpw;
  2838. }
  2839. }
  2840. $attr['SRC'] = $graph_img['file'];
  2841. $attr['WIDTH'] = $graph_img['w'];
  2842. $attr['HEIGHT'] = $graph_img['h'];
  2843. } else {
  2844. break;
  2845. }
  2846. // *********** IMAGE ********************
  2847. /* -- IMAGES-CORE -- */
  2848. case 'IMG':
  2849. $this->mpdf->ignorefollowingspaces = false;
  2850. if ($this->mpdf->progressBar) {
  2851. $this->mpdf->UpdateProgressBar(1, '', 'IMG');
  2852. } // *PROGRESS-BAR*
  2853. $objattr = array();
  2854. $objattr['margin_top'] = 0;
  2855. $objattr['margin_bottom'] = 0;
  2856. $objattr['margin_left'] = 0;
  2857. $objattr['margin_right'] = 0;
  2858. $objattr['padding_top'] = 0;
  2859. $objattr['padding_bottom'] = 0;
  2860. $objattr['padding_left'] = 0;
  2861. $objattr['padding_right'] = 0;
  2862. $objattr['width'] = 0;
  2863. $objattr['height'] = 0;
  2864. $objattr['border_top']['w'] = 0;
  2865. $objattr['border_bottom']['w'] = 0;
  2866. $objattr['border_left']['w'] = 0;
  2867. $objattr['border_right']['w'] = 0;
  2868. if (isset($attr['SRC'])) {
  2869. $srcpath = $attr['SRC'];
  2870. $orig_srcpath = (isset($attr['ORIG_SRC']) ? $attr['ORIG_SRC'] : '');
  2871. $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
  2872. if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
  2873. return;
  2874. }
  2875. if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) {
  2876. $v = intval($properties['Z-INDEX']);
  2877. if ($v > 0) {
  2878. $objattr['z-index'] = $v;
  2879. }
  2880. }
  2881. $objattr['visibility'] = 'visible';
  2882. if (isset($properties['VISIBILITY'])) {
  2883. $v = strtolower($properties['VISIBILITY']);
  2884. if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
  2885. $objattr['visibility'] = $v;
  2886. }
  2887. }
  2888. // VSPACE and HSPACE converted to margins in MergeCSS
  2889. if (isset($properties['MARGIN-TOP'])) {
  2890. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2891. }
  2892. if (isset($properties['MARGIN-BOTTOM'])) {
  2893. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2894. }
  2895. if (isset($properties['MARGIN-LEFT'])) {
  2896. $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2897. }
  2898. if (isset($properties['MARGIN-RIGHT'])) {
  2899. $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2900. }
  2901. if (isset($properties['PADDING-TOP'])) {
  2902. $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2903. }
  2904. if (isset($properties['PADDING-BOTTOM'])) {
  2905. $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2906. }
  2907. if (isset($properties['PADDING-LEFT'])) {
  2908. $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2909. }
  2910. if (isset($properties['PADDING-RIGHT'])) {
  2911. $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2912. }
  2913. if (isset($properties['BORDER-TOP'])) {
  2914. $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  2915. }
  2916. if (isset($properties['BORDER-BOTTOM'])) {
  2917. $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  2918. }
  2919. if (isset($properties['BORDER-LEFT'])) {
  2920. $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  2921. }
  2922. if (isset($properties['BORDER-RIGHT'])) {
  2923. $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  2924. }
  2925. if (isset($properties['VERTICAL-ALIGN'])) {
  2926. $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  2927. }
  2928. $w = 0;
  2929. $h = 0;
  2930. if (isset($properties['WIDTH']))
  2931. $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2932. else if (isset($attr['WIDTH']))
  2933. $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2934. if (isset($properties['HEIGHT']))
  2935. $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2936. else if (isset($attr['HEIGHT']))
  2937. $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2938. $maxw = $maxh = $minw = $minh = false;
  2939. if (isset($properties['MAX-WIDTH']))
  2940. $maxw = $this->mpdf->ConvertSize($properties['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2941. else if (isset($attr['MAX-WIDTH']))
  2942. $maxw = $this->mpdf->ConvertSize($attr['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2943. if (isset($properties['MAX-HEIGHT']))
  2944. $maxh = $this->mpdf->ConvertSize($properties['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2945. else if (isset($attr['MAX-HEIGHT']))
  2946. $maxh = $this->mpdf->ConvertSize($attr['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2947. if (isset($properties['MIN-WIDTH']))
  2948. $minw = $this->mpdf->ConvertSize($properties['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2949. else if (isset($attr['MIN-WIDTH']))
  2950. $minw = $this->mpdf->ConvertSize($attr['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2951. if (isset($properties['MIN-HEIGHT']))
  2952. $minh = $this->mpdf->ConvertSize($properties['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2953. else if (isset($attr['MIN-HEIGHT']))
  2954. $minh = $this->mpdf->ConvertSize($attr['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  2955. if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
  2956. $objattr['opacity'] = $properties['OPACITY'];
  2957. }
  2958. if ($this->mpdf->HREF) {
  2959. if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
  2960. $href = $this->mpdf->HREF;
  2961. while (array_key_exists($href, $this->mpdf->internallink))
  2962. $href = "#" . $href;
  2963. $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
  2964. $objattr['link'] = $this->mpdf->internallink[$href];
  2965. } else {
  2966. $objattr['link'] = $this->mpdf->HREF;
  2967. }
  2968. }
  2969. $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
  2970. $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
  2971. // mPDF 5.7.3 TRANSFORMS
  2972. if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
  2973. $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
  2974. }
  2975. /* -- BACKGROUNDS -- */
  2976. if (isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $properties['GRADIENT-MASK'])) {
  2977. $objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK'];
  2978. }
  2979. /* -- END BACKGROUNDS -- */
  2980. // mPDF 6
  2981. $interpolation = false;
  2982. if (isset($properties['IMAGE-RENDERING']) && $properties['IMAGE-RENDERING']) {
  2983. if (strtolower($properties['IMAGE-RENDERING']) == 'crisp-edges') {
  2984. $interpolation = false;
  2985. } else if (strtolower($properties['IMAGE-RENDERING']) == 'optimizequality') {
  2986. $interpolation = true;
  2987. } else if (strtolower($properties['IMAGE-RENDERING']) == 'smooth') {
  2988. $interpolation = true;
  2989. } else if (strtolower($properties['IMAGE-RENDERING']) == 'auto') {
  2990. $interpolation = $this->mpdf->interpolateImages;
  2991. } else {
  2992. $interpolation = false;
  2993. }
  2994. $info['interpolation'] = $interpolation;
  2995. }
  2996. // Image file
  2997. $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath, $interpolation); // mPDF 6
  2998. if (!$info) {
  2999. $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
  3000. if ($info) {
  3001. $srcpath = $this->mpdf->noImageFile;
  3002. $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
  3003. $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
  3004. }
  3005. }
  3006. if (!$info)
  3007. break;
  3008. if (isset($attr['ROTATE'])) {
  3009. $image_orientation = $attr['ROTATE'];
  3010. } else if (isset($properties['IMAGE-ORIENTATION'])) {
  3011. $image_orientation = $properties['IMAGE-ORIENTATION'];
  3012. } else {
  3013. $image_orientation = 0;
  3014. }
  3015. if ($image_orientation) {
  3016. if ($image_orientation == 90 || $image_orientation == -90 || $image_orientation == 270) {
  3017. $tmpw = $info['w'];
  3018. $info['w'] = $info['h'];
  3019. $info['h'] = $tmpw;
  3020. }
  3021. $objattr['ROTATE'] = $image_orientation;
  3022. }
  3023. $objattr['file'] = $srcpath;
  3024. //Default width and height calculation if needed
  3025. if ($w == 0 and $h == 0) {
  3026. /* -- IMAGES-WMF -- */
  3027. if ($info['type'] == 'wmf') {
  3028. // WMF units are twips (1/20pt)
  3029. // divide by 20 to get points
  3030. // divide by k to get user units
  3031. $w = abs($info['w']) / (20 * _MPDFK);
  3032. $h = abs($info['h']) / (20 * _MPDFK);
  3033. } else
  3034. /* -- END IMAGES-WMF -- */
  3035. if ($info['type'] == 'svg') {
  3036. // SVG units are pixels
  3037. $w = abs($info['w']) / _MPDFK;
  3038. $h = abs($info['h']) / _MPDFK;
  3039. } else {
  3040. //Put image at default image dpi
  3041. $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
  3042. $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
  3043. }
  3044. if (isset($properties['IMAGE-RESOLUTION'])) {
  3045. if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) {
  3046. $w *= $this->mpdf->img_dpi / $info['set-dpi'];
  3047. $h *= $this->mpdf->img_dpi / $info['set-dpi'];
  3048. } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
  3049. $dpi = $m[1];
  3050. if ($dpi > 0) {
  3051. $w *= $this->mpdf->img_dpi / $dpi;
  3052. $h *= $this->mpdf->img_dpi / $dpi;
  3053. }
  3054. }
  3055. }
  3056. }
  3057. // IF WIDTH OR HEIGHT SPECIFIED
  3058. if ($w == 0)
  3059. $w = abs($h * $info['w'] / $info['h']);
  3060. if ($h == 0)
  3061. $h = abs($w * $info['h'] / $info['w']);
  3062. if ($minw && $w < $minw) {
  3063. $w = $minw;
  3064. $h = abs($w * $info['h'] / $info['w']);
  3065. }
  3066. if ($maxw && $w > $maxw) {
  3067. $w = $maxw;
  3068. $h = abs($w * $info['h'] / $info['w']);
  3069. }
  3070. if ($minh && $h < $minh) {
  3071. $h = $minh;
  3072. $w = abs($h * $info['w'] / $info['h']);
  3073. }
  3074. if ($maxh && $h > $maxh) {
  3075. $h = $maxh;
  3076. $w = abs($h * $info['w'] / $info['h']);
  3077. }
  3078. // Resize to maximum dimensions of page
  3079. $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
  3080. $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1);
  3081. if ($this->mpdf->fullImageHeight) {
  3082. $maxHeight = $this->mpdf->fullImageHeight;
  3083. }
  3084. if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
  3085. $w = $maxWidth - $extrawidth;
  3086. $h = abs($w * $info['h'] / $info['w']);
  3087. }
  3088. if ($h + $extraheight > $maxHeight) {
  3089. $h = $maxHeight - $extraheight;
  3090. $w = abs($h * $info['w'] / $info['h']);
  3091. }
  3092. $objattr['type'] = 'image';
  3093. $objattr['itype'] = $info['type'];
  3094. $objattr['orig_h'] = $info['h'];
  3095. $objattr['orig_w'] = $info['w'];
  3096. /* -- IMAGES-WMF -- */
  3097. if ($info['type'] == 'wmf') {
  3098. $objattr['wmf_x'] = $info['x'];
  3099. $objattr['wmf_y'] = $info['y'];
  3100. } else
  3101. /* -- END IMAGES-WMF -- */
  3102. if ($info['type'] == 'svg') {
  3103. $objattr['wmf_x'] = $info['x'];
  3104. $objattr['wmf_y'] = $info['y'];
  3105. }
  3106. $objattr['height'] = $h + $extraheight;
  3107. $objattr['width'] = $w + $extrawidth;
  3108. $objattr['image_height'] = $h;
  3109. $objattr['image_width'] = $w;
  3110. /* -- CSS-IMAGE-FLOAT -- */
  3111. if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) {
  3112. if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
  3113. $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1);
  3114. }
  3115. }
  3116. /* -- END CSS-IMAGE-FLOAT -- */
  3117. // mPDF 5.7.3 TRANSFORMS
  3118. if (isset($properties['TRANSFORM']) && !$this->mpdf->ColActive && !$this->mpdf->kwt) {
  3119. $objattr['transform'] = $properties['TRANSFORM'];
  3120. }
  3121. $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  3122. // Clear properties - tidy up
  3123. $properties = array();
  3124. /* -- TABLES -- */
  3125. // Output it to buffers
  3126. if ($this->mpdf->tableLevel) {
  3127. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  3128. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
  3129. } else {
  3130. /* -- END TABLES -- */
  3131. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  3132. } // *TABLES*
  3133. /* -- ANNOTATIONS -- */
  3134. if ($this->mpdf->title2annots && isset($attr['TITLE'])) {
  3135. $objattr = array();
  3136. $objattr['margin_top'] = 0;
  3137. $objattr['margin_bottom'] = 0;
  3138. $objattr['margin_left'] = 0;
  3139. $objattr['margin_right'] = 0;
  3140. $objattr['width'] = 0;
  3141. $objattr['height'] = 0;
  3142. $objattr['border_top']['w'] = 0;
  3143. $objattr['border_bottom']['w'] = 0;
  3144. $objattr['border_left']['w'] = 0;
  3145. $objattr['border_right']['w'] = 0;
  3146. $objattr['CONTENT'] = $attr['TITLE'];
  3147. $objattr['type'] = 'annot';
  3148. $objattr['POS-X'] = 0;
  3149. $objattr['POS-Y'] = 0;
  3150. $objattr['ICON'] = 'Comment';
  3151. $objattr['AUTHOR'] = '';
  3152. $objattr['SUBJECT'] = '';
  3153. $objattr['OPACITY'] = $this->mpdf->annotOpacity;
  3154. $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
  3155. $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  3156. if ($this->mpdf->tableLevel) { // *TABLES*
  3157. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); // *TABLES*
  3158. } // *TABLES*
  3159. else { // *TABLES*
  3160. $this->mpdf->textbuffer[] = array($e);
  3161. } // *TABLES*
  3162. }
  3163. /* -- END ANNOTATIONS -- */
  3164. }
  3165. break;
  3166. /* -- END IMAGES-CORE -- */
  3167. // *********** CIRCULAR TEXT = TEXTCIRCLE ********************
  3168. case 'TEXTCIRCLE':
  3169. $objattr = array();
  3170. $objattr['margin_top'] = 0;
  3171. $objattr['margin_bottom'] = 0;
  3172. $objattr['margin_left'] = 0;
  3173. $objattr['margin_right'] = 0;
  3174. $objattr['padding_top'] = 0;
  3175. $objattr['padding_bottom'] = 0;
  3176. $objattr['padding_left'] = 0;
  3177. $objattr['padding_right'] = 0;
  3178. $objattr['width'] = 0;
  3179. $objattr['height'] = 0;
  3180. $objattr['border_top']['w'] = 0;
  3181. $objattr['border_bottom']['w'] = 0;
  3182. $objattr['border_left']['w'] = 0;
  3183. $objattr['border_right']['w'] = 0;
  3184. $objattr['top-text'] = '';
  3185. $objattr['bottom-text'] = '';
  3186. $objattr['r'] = 20; // radius (default value here for safety)
  3187. $objattr['space-width'] = 120;
  3188. $objattr['char-width'] = 100;
  3189. $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
  3190. $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
  3191. if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
  3192. return;
  3193. }
  3194. if (isset($attr['R'])) {
  3195. $objattr['r'] = $this->mpdf->ConvertSize($attr['R'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3196. }
  3197. if (isset($attr['TOP-TEXT'])) {
  3198. $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
  3199. $objattr['top-text'] = $this->mpdf->lesser_entity_decode($objattr['top-text']);
  3200. if ($this->mpdf->onlyCoreFonts)
  3201. $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mpdf->mb_enc, 'UTF-8');
  3202. }
  3203. if (isset($attr['BOTTOM-TEXT'])) {
  3204. $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
  3205. $objattr['bottom-text'] = $this->mpdf->lesser_entity_decode($objattr['bottom-text']);
  3206. if ($this->mpdf->onlyCoreFonts)
  3207. $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mpdf->mb_enc, 'UTF-8');
  3208. }
  3209. if (isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) {
  3210. $objattr['space-width'] = $attr['SPACE-WIDTH'];
  3211. }
  3212. if (isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) {
  3213. $objattr['char-width'] = $attr['CHAR-WIDTH'];
  3214. }
  3215. // VISIBILITY
  3216. $objattr['visibility'] = 'visible';
  3217. if (isset($properties['VISIBILITY'])) {
  3218. $v = strtolower($properties['VISIBILITY']);
  3219. if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
  3220. $objattr['visibility'] = $v;
  3221. }
  3222. }
  3223. if (isset($properties['FONT-SIZE'])) {
  3224. if (strtolower($properties['FONT-SIZE']) == 'auto') {
  3225. if ($objattr['top-text'] && $objattr['bottom-text']) {
  3226. $objattr['fontsize'] = -2;
  3227. } else {
  3228. $objattr['fontsize'] = -1;
  3229. }
  3230. } else {
  3231. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK));
  3232. $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
  3233. $objattr['fontsize'] = $this->mpdf->FontSizePt;
  3234. }
  3235. }
  3236. if (isset($attr['DIVIDER'])) {
  3237. $objattr['divider'] = strcode2utf($attr['DIVIDER']);
  3238. $objattr['divider'] = $this->mpdf->lesser_entity_decode($objattr['divider']);
  3239. if ($this->mpdf->onlyCoreFonts)
  3240. $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mpdf->mb_enc, 'UTF-8');
  3241. }
  3242. if (isset($properties['COLOR'])) {
  3243. $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
  3244. }
  3245. $objattr['fontstyle'] = '';
  3246. if (isset($properties['FONT-WEIGHT'])) {
  3247. if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
  3248. $objattr['fontstyle'] .= 'B';
  3249. }
  3250. }
  3251. if (isset($properties['FONT-STYLE'])) {
  3252. if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
  3253. $objattr['fontstyle'] .= 'I';
  3254. }
  3255. }
  3256. if (isset($properties['FONT-FAMILY'])) {
  3257. $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
  3258. }
  3259. $objattr['fontfamily'] = $this->mpdf->FontFamily;
  3260. // VSPACE and HSPACE converted to margins in MergeCSS
  3261. if (isset($properties['MARGIN-TOP'])) {
  3262. $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3263. }
  3264. if (isset($properties['MARGIN-BOTTOM'])) {
  3265. $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3266. }
  3267. if (isset($properties['MARGIN-LEFT'])) {
  3268. $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3269. }
  3270. if (isset($properties['MARGIN-RIGHT'])) {
  3271. $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3272. }
  3273. if (isset($properties['PADDING-TOP'])) {
  3274. $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3275. }
  3276. if (isset($properties['PADDING-BOTTOM'])) {
  3277. $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3278. }
  3279. if (isset($properties['PADDING-LEFT'])) {
  3280. $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3281. }
  3282. if (isset($properties['PADDING-RIGHT'])) {
  3283. $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3284. }
  3285. if (isset($properties['BORDER-TOP'])) {
  3286. $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  3287. }
  3288. if (isset($properties['BORDER-BOTTOM'])) {
  3289. $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  3290. }
  3291. if (isset($properties['BORDER-LEFT'])) {
  3292. $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  3293. }
  3294. if (isset($properties['BORDER-RIGHT'])) {
  3295. $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  3296. }
  3297. if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
  3298. $objattr['opacity'] = $properties['OPACITY'];
  3299. }
  3300. if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
  3301. $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
  3302. } else {
  3303. $objattr['bgcolor'] = false;
  3304. }
  3305. if ($this->mpdf->HREF) {
  3306. if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
  3307. $href = $this->mpdf->HREF;
  3308. while (array_key_exists($href, $this->mpdf->internallink))
  3309. $href = "#" . $href;
  3310. $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
  3311. $objattr['link'] = $this->mpdf->internallink[$href];
  3312. } else {
  3313. $objattr['link'] = $this->mpdf->HREF;
  3314. }
  3315. }
  3316. $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
  3317. $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
  3318. $w = $objattr['r'] * 2;
  3319. $h = $w;
  3320. $objattr['height'] = $h + $extraheight;
  3321. $objattr['width'] = $w + $extrawidth;
  3322. $objattr['type'] = 'textcircle';
  3323. $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  3324. // Clear properties - tidy up
  3325. $properties = array();
  3326. /* -- TABLES -- */
  3327. // Output it to buffers
  3328. if ($this->mpdf->tableLevel) {
  3329. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  3330. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
  3331. } else {
  3332. /* -- END TABLES -- */
  3333. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  3334. } // *TABLES*
  3335. if ($this->mpdf->InlineProperties[$tag]) {
  3336. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  3337. }
  3338. unset($this->mpdf->InlineProperties[$tag]);
  3339. break;
  3340. /* -- TABLES -- */
  3341. case 'TABLE': // TABLE-BEGIN
  3342. $this->mpdf->tdbegin = false;
  3343. $this->mpdf->lastoptionaltag = '';
  3344. // Disable vertical justification in columns
  3345. if ($this->mpdf->ColActive) {
  3346. $this->mpdf->colvAlign = '';
  3347. } // *COLUMNS*
  3348. if ($this->mpdf->lastblocklevelchange == 1) {
  3349. $blockstate = 1;
  3350. } // Top margins/padding only
  3351. else if ($this->mpdf->lastblocklevelchange < 1) {
  3352. $blockstate = 0;
  3353. } // NO margins/padding
  3354. // called from block after new div e.g. <div> ... <table> ... Outputs block top margin/border and padding
  3355. if (count($this->mpdf->textbuffer) == 0 && $this->mpdf->lastblocklevelchange == 1 && !$this->mpdf->tableLevel && !$this->mpdf->kwt) {
  3356. $this->mpdf->newFlowingBlock($this->mpdf->blk[$this->mpdf->blklvl]['width'], $this->mpdf->lineheight, '', false, 1, true, $this->mpdf->blk[$this->mpdf->blklvl]['direction']);
  3357. $this->mpdf->finishFlowingBlock(true); // true = END of flowing block
  3358. } else if (!$this->mpdf->tableLevel && count($this->mpdf->textbuffer)) {
  3359. $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
  3360. }
  3361. $this->mpdf->textbuffer = array();
  3362. $this->mpdf->lastblocklevelchange = -1;
  3363. if ($this->mpdf->tableLevel) { // i.e. now a nested table coming...
  3364. // Save current level table
  3365. $this->mpdf->cell['PARENTCELL'] = $this->mpdf->saveInlineProperties();
  3366. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['baseProperties'] = $this->mpdf->base_table_properties;
  3367. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = $this->mpdf->cell;
  3368. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currrow'] = $this->mpdf->row;
  3369. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currcol'] = $this->mpdf->col;
  3370. }
  3371. $this->mpdf->tableLevel++;
  3372. $this->mpdf->cssmgr->tbCSSlvl++;
  3373. if ($this->mpdf->tableLevel > 1) { // inherit table properties from cell in which nested
  3374. //$this->mpdf->base_table_properties['FONT-KERNING'] = ($this->mpdf->textvar & FC_KERNING); // mPDF 6
  3375. $this->mpdf->base_table_properties['LETTER-SPACING'] = $this->mpdf->lSpacingCSS;
  3376. $this->mpdf->base_table_properties['WORD-SPACING'] = $this->mpdf->wSpacingCSS;
  3377. // mPDF 6
  3378. $direction = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction'];
  3379. $txta = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'];
  3380. $cellLineHeight = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineHeight'];
  3381. $cellLineStackingStrategy = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineStackingStrategy'];
  3382. $cellLineStackingShift = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineStackingShift'];
  3383. }
  3384. if (isset($this->mpdf->tbctr[$this->mpdf->tableLevel])) {
  3385. $this->mpdf->tbctr[$this->mpdf->tableLevel] ++;
  3386. } else {
  3387. $this->mpdf->tbctr[$this->mpdf->tableLevel] = 1;
  3388. }
  3389. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['level'] = $this->mpdf->tableLevel;
  3390. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['levelid'] = $this->mpdf->tbctr[$this->mpdf->tableLevel];
  3391. if ($this->mpdf->tableLevel > $this->mpdf->innermostTableLevel) {
  3392. $this->mpdf->innermostTableLevel = $this->mpdf->tableLevel;
  3393. }
  3394. if ($this->mpdf->tableLevel > 1) {
  3395. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nestedpos'] = array($this->mpdf->row, $this->mpdf->col, $this->mpdf->tbctr[($this->mpdf->tableLevel - 1)]);
  3396. }
  3397. //++++++++++++++++++++++++++++
  3398. $this->mpdf->cell = array();
  3399. $this->mpdf->col = -1; //int
  3400. $this->mpdf->row = -1; //int
  3401. $table = &$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]];
  3402. // New table - any level
  3403. $table['direction'] = $this->mpdf->directionality;
  3404. $table['bgcolor'] = false;
  3405. $table['va'] = false;
  3406. $table['txta'] = false;
  3407. $table['topntail'] = false;
  3408. $table['thead-underline'] = false;
  3409. $table['border'] = false;
  3410. $table['border_details']['R']['w'] = 0;
  3411. $table['border_details']['L']['w'] = 0;
  3412. $table['border_details']['T']['w'] = 0;
  3413. $table['border_details']['B']['w'] = 0;
  3414. $table['border_details']['R']['style'] = '';
  3415. $table['border_details']['L']['style'] = '';
  3416. $table['border_details']['T']['style'] = '';
  3417. $table['border_details']['B']['style'] = '';
  3418. $table['max_cell_border_width']['R'] = 0;
  3419. $table['max_cell_border_width']['L'] = 0;
  3420. $table['max_cell_border_width']['T'] = 0;
  3421. $table['max_cell_border_width']['B'] = 0;
  3422. $table['padding']['L'] = false;
  3423. $table['padding']['R'] = false;
  3424. $table['padding']['T'] = false;
  3425. $table['padding']['B'] = false;
  3426. $table['margin']['L'] = false;
  3427. $table['margin']['R'] = false;
  3428. $table['margin']['T'] = false;
  3429. $table['margin']['B'] = false;
  3430. $table['a'] = false;
  3431. $table['border_spacing_H'] = false;
  3432. $table['border_spacing_V'] = false;
  3433. $table['decimal_align'] = false;
  3434. $this->mpdf->Reset();
  3435. $this->mpdf->InlineProperties = array();
  3436. $this->mpdf->InlineBDF = array(); // mPDF 6
  3437. $this->mpdf->InlineBDFctr = 0; // mPDF 6
  3438. $table['nc'] = $table['nr'] = 0;
  3439. $this->mpdf->tablethead = 0;
  3440. $this->mpdf->tabletfoot = 0;
  3441. $this->mpdf->tabletheadjustfinished = false;
  3442. // mPDF 6
  3443. if ($this->mpdf->tableLevel > 1) { // inherit table properties from cell in which nested
  3444. $table['direction'] = $direction;
  3445. $table['txta'] = $txta;
  3446. $table['cellLineHeight'] = $cellLineHeight;
  3447. $table['cellLineStackingStrategy'] = $cellLineStackingStrategy;
  3448. $table['cellLineStackingShift'] = $cellLineStackingShift;
  3449. }
  3450. if ($this->mpdf->blockjustfinished && !count($this->mpdf->textbuffer) && $this->mpdf->y != $this->mpdf->tMargin && $this->mpdf->collapseBlockMargins && $this->mpdf->tableLevel == 1) {
  3451. $lastbottommargin = $this->mpdf->lastblockbottommargin;
  3452. } else {
  3453. $lastbottommargin = 0;
  3454. }
  3455. $this->mpdf->lastblockbottommargin = 0;
  3456. $this->mpdf->blockjustfinished = false;
  3457. if ($this->mpdf->tableLevel == 1) {
  3458. $table['headernrows'] = 0;
  3459. $table['footernrows'] = 0;
  3460. $this->mpdf->base_table_properties = array();
  3461. }
  3462. // ADDED CSS FUNCIONS FOR TABLE
  3463. if ($this->mpdf->cssmgr->tbCSSlvl == 1) {
  3464. $properties = $this->mpdf->cssmgr->MergeCSS('TOPTABLE', $tag, $attr);
  3465. } else {
  3466. $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  3467. }
  3468. $w = '';
  3469. if (isset($properties['WIDTH'])) {
  3470. $w = $properties['WIDTH'];
  3471. } else if (isset($attr['WIDTH']) && $attr['WIDTH']) {
  3472. $w = $attr['WIDTH'];
  3473. }
  3474. if (isset($attr['ALIGN']) && isset($align[strtolower($attr['ALIGN'])])) {
  3475. $table['a'] = $align[strtolower($attr['ALIGN'])];
  3476. }
  3477. if (!$table['a']) {
  3478. if ($table['direction'] == 'rtl') {
  3479. $table['a'] = 'R';
  3480. } else {
  3481. $table['a'] = 'L';
  3482. }
  3483. }
  3484. if (isset($properties['DIRECTION']) && $properties['DIRECTION']) {
  3485. $table['direction'] = strtolower($properties['DIRECTION']);
  3486. } else if (isset($attr['DIR']) && $attr['DIR']) {
  3487. $table['direction'] = strtolower($attr['DIR']);
  3488. } else if ($this->mpdf->tableLevel == 1) {
  3489. $table['direction'] = $this->mpdf->blk[$this->mpdf->blklvl]['direction'];
  3490. }
  3491. if (isset($properties['BACKGROUND-COLOR'])) {
  3492. $table['bgcolor'][-1] = $properties['BACKGROUND-COLOR'];
  3493. } else if (isset($properties['BACKGROUND'])) {
  3494. $table['bgcolor'][-1] = $properties['BACKGROUND'];
  3495. } else if (isset($attr['BGCOLOR'])) {
  3496. $table['bgcolor'][-1] = $attr['BGCOLOR'];
  3497. }
  3498. if (isset($properties['VERTICAL-ALIGN']) && isset($align[strtolower($properties['VERTICAL-ALIGN'])])) {
  3499. $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  3500. }
  3501. if (isset($properties['TEXT-ALIGN']) && isset($align[strtolower($properties['TEXT-ALIGN'])])) {
  3502. $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])];
  3503. }
  3504. if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->mpdf->tableLevel == 1) {
  3505. $this->mpdf->shrink_this_table_to_fit = $properties['AUTOSIZE'];
  3506. if ($this->mpdf->shrink_this_table_to_fit < 1) {
  3507. $this->mpdf->shrink_this_table_to_fit = 0;
  3508. }
  3509. }
  3510. if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->mpdf->tableLevel == 1) {
  3511. $this->mpdf->table_rotate = $properties['ROTATE'];
  3512. }
  3513. if (isset($properties['TOPNTAIL'])) {
  3514. $table['topntail'] = $properties['TOPNTAIL'];
  3515. }
  3516. if (isset($properties['THEAD-UNDERLINE'])) {
  3517. $table['thead-underline'] = $properties['THEAD-UNDERLINE'];
  3518. }
  3519. if (isset($properties['BORDER'])) {
  3520. $bord = $this->mpdf->border_details($properties['BORDER']);
  3521. if ($bord['s']) {
  3522. $table['border'] = _BORDER_ALL;
  3523. $table['border_details']['R'] = $bord;
  3524. $table['border_details']['L'] = $bord;
  3525. $table['border_details']['T'] = $bord;
  3526. $table['border_details']['B'] = $bord;
  3527. }
  3528. }
  3529. if (isset($properties['BORDER-RIGHT'])) {
  3530. if ($table['direction'] == 'rtl') { // *OTL*
  3531. $table['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-LEFT']); // *OTL*
  3532. } // *OTL*
  3533. else { // *OTL*
  3534. $table['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  3535. } // *OTL*
  3536. $this->mpdf->setBorder($table['border'], _BORDER_RIGHT, $table['border_details']['R']['s']);
  3537. }
  3538. if (isset($properties['BORDER-LEFT'])) {
  3539. if ($table['direction'] == 'rtl') { // *OTL*
  3540. $table['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); // *OTL*
  3541. } // *OTL*
  3542. else { // *OTL*
  3543. $table['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  3544. } // *OTL*
  3545. $this->mpdf->setBorder($table['border'], _BORDER_LEFT, $table['border_details']['L']['s']);
  3546. }
  3547. if (isset($properties['BORDER-BOTTOM'])) {
  3548. $table['border_details']['B'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  3549. $this->mpdf->setBorder($table['border'], _BORDER_BOTTOM, $table['border_details']['B']['s']);
  3550. }
  3551. if (isset($properties['BORDER-TOP'])) {
  3552. $table['border_details']['T'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  3553. $this->mpdf->setBorder($table['border'], _BORDER_TOP, $table['border_details']['T']['s']);
  3554. }
  3555. if ($table['border']) {
  3556. $this->mpdf->table_border_css_set = 1;
  3557. } else {
  3558. $this->mpdf->table_border_css_set = 0;
  3559. }
  3560. // mPDF 6
  3561. if (isset($properties['LANG']) && $properties['LANG']) {
  3562. if ($this->mpdf->autoLangToFont && !$this->mpdf->usingCoreFont) {
  3563. if ($properties['LANG'] != $this->mpdf->default_lang && $properties['LANG'] != 'UTF-8') {
  3564. list ($coreSuitable, $mpdf_pdf_unifont) = GetLangOpts($properties['LANG'], $this->mpdf->useAdobeCJK, $this->mpdf->fontdata);
  3565. if ($mpdf_pdf_unifont) {
  3566. $properties['FONT-FAMILY'] = $mpdf_pdf_unifont;
  3567. }
  3568. }
  3569. }
  3570. $this->mpdf->currentLang = $properties['LANG'];
  3571. }
  3572. if (isset($properties['FONT-FAMILY'])) {
  3573. $this->mpdf->default_font = $properties['FONT-FAMILY'];
  3574. $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
  3575. }
  3576. $this->mpdf->base_table_properties['FONT-FAMILY'] = $this->mpdf->FontFamily;
  3577. if (isset($properties['FONT-SIZE'])) {
  3578. if ($this->mpdf->tableLevel > 1) {
  3579. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->base_table_properties['FONT-SIZE']);
  3580. } else {
  3581. $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
  3582. }
  3583. if ($mmsize) {
  3584. $this->mpdf->default_font_size = $mmsize * (_MPDFK);
  3585. $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
  3586. }
  3587. }
  3588. $this->mpdf->base_table_properties['FONT-SIZE'] = $this->mpdf->FontSize . 'mm';
  3589. if (isset($properties['FONT-WEIGHT'])) {
  3590. if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
  3591. $this->mpdf->base_table_properties['FONT-WEIGHT'] = 'BOLD';
  3592. }
  3593. }
  3594. if (isset($properties['FONT-STYLE'])) {
  3595. if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
  3596. $this->mpdf->base_table_properties['FONT-STYLE'] = 'ITALIC';
  3597. }
  3598. }
  3599. if (isset($properties['COLOR'])) {
  3600. $this->mpdf->base_table_properties['COLOR'] = $properties['COLOR'];
  3601. }
  3602. if (isset($properties['FONT-KERNING'])) {
  3603. $this->mpdf->base_table_properties['FONT-KERNING'] = $properties['FONT-KERNING'];
  3604. }
  3605. if (isset($properties['LETTER-SPACING'])) {
  3606. $this->mpdf->base_table_properties['LETTER-SPACING'] = $properties['LETTER-SPACING'];
  3607. }
  3608. if (isset($properties['WORD-SPACING'])) {
  3609. $this->mpdf->base_table_properties['WORD-SPACING'] = $properties['WORD-SPACING'];
  3610. }
  3611. // mPDF 6
  3612. if (isset($properties['HYPHENS'])) {
  3613. $this->mpdf->base_table_properties['HYPHENS'] = $properties['HYPHENS'];
  3614. }
  3615. if (isset($properties['LINE-HEIGHT']) && $properties['LINE-HEIGHT']) {
  3616. $table['cellLineHeight'] = $this->mpdf->fixLineheight($properties['LINE-HEIGHT']);
  3617. } else if ($this->mpdf->tableLevel == 1) {
  3618. $table['cellLineHeight'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_height'];
  3619. }
  3620. if (isset($properties['LINE-STACKING-STRATEGY']) && $properties['LINE-STACKING-STRATEGY']) {
  3621. $table['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']);
  3622. } else if ($this->mpdf->tableLevel == 1 && isset($this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_strategy'])) {
  3623. $table['cellLineStackingStrategy'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_strategy'];
  3624. } else {
  3625. $table['cellLineStackingStrategy'] = 'inline-line-height';
  3626. }
  3627. if (isset($properties['LINE-STACKING-SHIFT']) && $properties['LINE-STACKING-SHIFT']) {
  3628. $table['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']);
  3629. } else if ($this->mpdf->tableLevel == 1 && isset($this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_shift'])) {
  3630. $table['cellLineStackingShift'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_shift'];
  3631. } else {
  3632. $table['cellLineStackingShift'] = 'consider-shifts';
  3633. }
  3634. if (isset($properties['PADDING-LEFT'])) {
  3635. $table['padding']['L'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3636. }
  3637. if (isset($properties['PADDING-RIGHT'])) {
  3638. $table['padding']['R'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3639. }
  3640. if (isset($properties['PADDING-TOP'])) {
  3641. $table['padding']['T'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3642. }
  3643. if (isset($properties['PADDING-BOTTOM'])) {
  3644. $table['padding']['B'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3645. }
  3646. if (isset($properties['MARGIN-TOP'])) {
  3647. if ($lastbottommargin) {
  3648. $tmp = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3649. if ($tmp > $lastbottommargin) {
  3650. $properties['MARGIN-TOP'] -= $lastbottommargin;
  3651. } else {
  3652. $properties['MARGIN-TOP'] = 0;
  3653. }
  3654. }
  3655. $table['margin']['T'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3656. }
  3657. if (isset($properties['MARGIN-BOTTOM'])) {
  3658. $table['margin']['B'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3659. }
  3660. if (isset($properties['MARGIN-LEFT'])) {
  3661. $table['margin']['L'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3662. }
  3663. if (isset($properties['MARGIN-RIGHT'])) {
  3664. $table['margin']['R'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3665. }
  3666. if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
  3667. $table['a'] = 'C';
  3668. } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
  3669. $table['a'] = 'R';
  3670. } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
  3671. $table['a'] = 'L';
  3672. }
  3673. if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE']) == 'SEPARATE') {
  3674. $table['borders_separate'] = true;
  3675. } else {
  3676. $table['borders_separate'] = false;
  3677. }
  3678. // mPDF 5.7.3
  3679. if (isset($properties['BORDER-SPACING-H'])) {
  3680. $table['border_spacing_H'] = $this->mpdf->ConvertSize($properties['BORDER-SPACING-H'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3681. }
  3682. if (isset($properties['BORDER-SPACING-V'])) {
  3683. $table['border_spacing_V'] = $this->mpdf->ConvertSize($properties['BORDER-SPACING-V'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3684. }
  3685. // mPDF 5.7.3
  3686. if (!$table['borders_separate']) {
  3687. $table['border_spacing_H'] = $table['border_spacing_V'] = 0;
  3688. }
  3689. if (isset($properties['EMPTY-CELLS'])) {
  3690. $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
  3691. } else {
  3692. $table['empty_cells'] = '';
  3693. }
  3694. if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && $this->mpdf->tableLevel == 1 && !$this->mpdf->writingHTMLfooter) {
  3695. $this->mpdf->table_keep_together = true;
  3696. } else if ($this->mpdf->tableLevel == 1) {
  3697. $this->mpdf->table_keep_together = false;
  3698. }
  3699. if (isset($properties['PAGE-BREAK-AFTER']) && $this->mpdf->tableLevel == 1) {
  3700. $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
  3701. }
  3702. /* -- BACKGROUNDS -- */
  3703. if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
  3704. $table['gradient'] = $properties['BACKGROUND-GRADIENT'];
  3705. }
  3706. if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
  3707. $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
  3708. if ($ret) {
  3709. $table['background-image'] = $ret;
  3710. }
  3711. }
  3712. /* -- END BACKGROUNDS -- */
  3713. if (isset($properties['OVERFLOW'])) {
  3714. $table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
  3715. if (($this->mpdf->ColActive || $this->mpdf->tableLevel > 1) && $table['overflow'] == 'visible') {
  3716. unset($table['overflow']);
  3717. }
  3718. }
  3719. $properties = array();
  3720. if (isset($attr['CELLPADDING'])) {
  3721. $table['cell_padding'] = $attr['CELLPADDING'];
  3722. } else {
  3723. $table['cell_padding'] = false;
  3724. }
  3725. if (isset($attr['BORDER']) && $attr['BORDER'] == '1') {
  3726. $this->mpdf->table_border_attr_set = 1;
  3727. $bord = $this->mpdf->border_details('#000000 1px solid');
  3728. if ($bord['s']) {
  3729. $table['border'] = _BORDER_ALL;
  3730. $table['border_details']['R'] = $bord;
  3731. $table['border_details']['L'] = $bord;
  3732. $table['border_details']['T'] = $bord;
  3733. $table['border_details']['B'] = $bord;
  3734. }
  3735. } else {
  3736. $this->mpdf->table_border_attr_set = 0;
  3737. }
  3738. if ($w) {
  3739. $maxwidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
  3740. if ($table['borders_separate']) {
  3741. $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['border_details']['L']['w'] / 2 + $table['border_details']['R']['w'] / 2;
  3742. } else {
  3743. $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L'] / 2 + $table['max_cell_border_width']['R'] / 2;
  3744. }
  3745. if (strpos($w, '%') && $this->mpdf->tableLevel == 1 && !$this->mpdf->ignore_table_percents) {
  3746. // % needs to be of inner box without table margins etc.
  3747. $maxwidth -= $tblblw;
  3748. $wmm = $this->mpdf->ConvertSize($w, $maxwidth, $this->mpdf->FontSize, false);
  3749. $table['w'] = $wmm + $tblblw;
  3750. }
  3751. if (strpos($w, '%') && $this->mpdf->tableLevel > 1 && !$this->mpdf->ignore_table_percents && $this->mpdf->keep_table_proportions) {
  3752. $table['wpercent'] = $w + 0; // makes 80% -> 80
  3753. }
  3754. if (!strpos($w, '%') && !$this->mpdf->ignore_table_widths) {
  3755. $wmm = $this->mpdf->ConvertSize($w, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  3756. $table['w'] = $wmm + $tblblw;
  3757. }
  3758. if (!$this->mpdf->keep_table_proportions) {
  3759. if (isset($table['w']) && $table['w'] > $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']) {
  3760. $table['w'] = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
  3761. }
  3762. }
  3763. }
  3764. if (isset($attr['AUTOSIZE']) && $this->mpdf->tableLevel == 1) {
  3765. $this->mpdf->shrink_this_table_to_fit = $attr['AUTOSIZE'];
  3766. if ($this->mpdf->shrink_this_table_to_fit < 1) {
  3767. $this->mpdf->shrink_this_table_to_fit = 1;
  3768. }
  3769. }
  3770. if (isset($attr['ROTATE']) && $this->mpdf->tableLevel == 1) {
  3771. $this->mpdf->table_rotate = $attr['ROTATE'];
  3772. }
  3773. //++++++++++++++++++++++++++++
  3774. if ($this->mpdf->table_rotate) {
  3775. $this->mpdf->tbrot_Links = array();
  3776. $this->mpdf->tbrot_Annots = array();
  3777. $this->mpdf->tbrotForms = array();
  3778. $this->mpdf->tbrot_BMoutlines = array();
  3779. $this->mpdf->tbrot_toc = array();
  3780. }
  3781. if ($this->mpdf->kwt) {
  3782. if ($this->mpdf->table_rotate) {
  3783. $this->mpdf->table_keep_together = true;
  3784. }
  3785. $this->mpdf->kwt = false;
  3786. $this->mpdf->kwt_saved = true;
  3787. }
  3788. if ($this->mpdf->tableLevel == 1 && $this->mpdf->useGraphs) {
  3789. if (isset($attr['ID']) && $attr['ID']) {
  3790. $this->mpdf->currentGraphId = strtoupper($attr['ID']);
  3791. } else {
  3792. $this->mpdf->currentGraphId = '0';
  3793. }
  3794. $this->mpdf->graphs[$this->mpdf->currentGraphId] = array();
  3795. }
  3796. //++++++++++++++++++++++++++++
  3797. $this->mpdf->plainCell_properties = array();
  3798. unset($table);
  3799. break;
  3800. case 'THEAD':
  3801. $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
  3802. $this->mpdf->cssmgr->tbCSSlvl++;
  3803. $this->mpdf->tablethead = 1;
  3804. $this->mpdf->tabletfoot = 0;
  3805. $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  3806. if (isset($properties['FONT-WEIGHT'])) {
  3807. if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
  3808. $this->mpdf->thead_font_weight = 'B';
  3809. } else {
  3810. $this->mpdf->thead_font_weight = '';
  3811. }
  3812. }
  3813. if (isset($properties['FONT-STYLE'])) {
  3814. if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
  3815. $this->mpdf->thead_font_style = 'I';
  3816. } else {
  3817. $this->mpdf->thead_font_style = '';
  3818. }
  3819. }
  3820. if (isset($properties['FONT-VARIANT'])) {
  3821. if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
  3822. $this->mpdf->thead_font_smCaps = 'S';
  3823. } else {
  3824. $this->mpdf->thead_font_smCaps = '';
  3825. }
  3826. }
  3827. if (isset($properties['VERTICAL-ALIGN'])) {
  3828. $this->mpdf->thead_valign_default = $properties['VERTICAL-ALIGN'];
  3829. }
  3830. if (isset($properties['TEXT-ALIGN'])) {
  3831. $this->mpdf->thead_textalign_default = $properties['TEXT-ALIGN'];
  3832. }
  3833. $properties = array();
  3834. break;
  3835. case 'TFOOT':
  3836. $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
  3837. $this->mpdf->cssmgr->tbCSSlvl++;
  3838. $this->mpdf->tabletfoot = 1;
  3839. $this->mpdf->tablethead = 0;
  3840. $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  3841. if (isset($properties['FONT-WEIGHT'])) {
  3842. if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
  3843. $this->mpdf->tfoot_font_weight = 'B';
  3844. } else {
  3845. $this->mpdf->tfoot_font_weight = '';
  3846. }
  3847. }
  3848. if (isset($properties['FONT-STYLE'])) {
  3849. if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
  3850. $this->mpdf->tfoot_font_style = 'I';
  3851. } else {
  3852. $this->mpdf->tfoot_font_style = '';
  3853. }
  3854. }
  3855. if (isset($properties['FONT-VARIANT'])) {
  3856. if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
  3857. $this->mpdf->tfoot_font_smCaps = 'S';
  3858. } else {
  3859. $this->mpdf->tfoot_font_smCaps = '';
  3860. }
  3861. }
  3862. if (isset($properties['VERTICAL-ALIGN'])) {
  3863. $this->mpdf->tfoot_valign_default = $properties['VERTICAL-ALIGN'];
  3864. }
  3865. if (isset($properties['TEXT-ALIGN'])) {
  3866. $this->mpdf->tfoot_textalign_default = $properties['TEXT-ALIGN'];
  3867. }
  3868. $properties = array();
  3869. break;
  3870. case 'TBODY':
  3871. $this->mpdf->tablethead = 0;
  3872. $this->mpdf->tabletfoot = 0;
  3873. $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
  3874. $this->mpdf->cssmgr->tbCSSlvl++;
  3875. $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  3876. break;
  3877. case 'TR':
  3878. $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
  3879. $this->mpdf->cssmgr->tbCSSlvl++;
  3880. $this->mpdf->row++;
  3881. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr'] ++;
  3882. $this->mpdf->col = -1;
  3883. $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  3884. if (!$this->mpdf->simpleTables && (!isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate']) || !$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate'])) {
  3885. if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
  3886. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row] = $properties['BORDER-LEFT'];
  3887. }
  3888. if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
  3889. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row] = $properties['BORDER-RIGHT'];
  3890. }
  3891. if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
  3892. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-top'][$this->mpdf->row] = $properties['BORDER-TOP'];
  3893. }
  3894. if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
  3895. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-bottom'][$this->mpdf->row] = $properties['BORDER-BOTTOM'];
  3896. }
  3897. }
  3898. if (isset($properties['BACKGROUND-COLOR'])) {
  3899. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $properties['BACKGROUND-COLOR'];
  3900. } else if (isset($attr['BGCOLOR']))
  3901. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $attr['BGCOLOR'];
  3902. /* -- BACKGROUNDS -- */
  3903. if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
  3904. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$this->mpdf->row] = $properties['BACKGROUND-GRADIENT'];
  3905. }
  3906. if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
  3907. $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
  3908. if ($ret) {
  3909. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$this->mpdf->row] = $ret;
  3910. }
  3911. }
  3912. /* -- END BACKGROUNDS -- */
  3913. if (isset($properties['TEXT-ROTATE'])) {
  3914. $this->mpdf->trow_text_rotate = $properties['TEXT-ROTATE'];
  3915. }
  3916. if (isset($attr['TEXT-ROTATE']))
  3917. $this->mpdf->trow_text_rotate = $attr['TEXT-ROTATE'];
  3918. if ($this->mpdf->tablethead) {
  3919. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'][$this->mpdf->row] = true;
  3920. }
  3921. if ($this->mpdf->tabletfoot) {
  3922. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$this->mpdf->row] = true;
  3923. }
  3924. $properties = array();
  3925. break;
  3926. case 'TH':
  3927. case 'TD':
  3928. $this->mpdf->ignorefollowingspaces = true;
  3929. $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
  3930. $this->mpdf->cssmgr->tbCSSlvl++;
  3931. $this->mpdf->InlineProperties = array();
  3932. $this->mpdf->InlineBDF = array(); // mPDF 6
  3933. $this->mpdf->InlineBDFctr = 0; // mPDF 6
  3934. $this->mpdf->tdbegin = true;
  3935. $this->mpdf->col++;
  3936. while (isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col])) {
  3937. $this->mpdf->col++;
  3938. }
  3939. //Update number column
  3940. if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] < $this->mpdf->col + 1) {
  3941. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] = $this->mpdf->col + 1;
  3942. }
  3943. $table = &$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]];
  3944. $c = array('a' => false,
  3945. 'R' => false,
  3946. 'nowrap' => false,
  3947. 'bgcolor' => false,
  3948. 'padding' => array('L' => false,
  3949. 'R' => false,
  3950. 'T' => false,
  3951. 'B' => false
  3952. )
  3953. );
  3954. if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
  3955. $table['simple']['border'] = false;
  3956. $table['simple']['border_details']['R']['w'] = 0;
  3957. $table['simple']['border_details']['L']['w'] = 0;
  3958. $table['simple']['border_details']['T']['w'] = 0;
  3959. $table['simple']['border_details']['B']['w'] = 0;
  3960. $table['simple']['border_details']['R']['style'] = '';
  3961. $table['simple']['border_details']['L']['style'] = '';
  3962. $table['simple']['border_details']['T']['style'] = '';
  3963. $table['simple']['border_details']['B']['style'] = '';
  3964. } else if (!$this->mpdf->simpleTables) {
  3965. $c['border'] = false;
  3966. $c['border_details']['R']['w'] = 0;
  3967. $c['border_details']['L']['w'] = 0;
  3968. $c['border_details']['T']['w'] = 0;
  3969. $c['border_details']['B']['w'] = 0;
  3970. $c['border_details']['mbw']['BL'] = 0;
  3971. $c['border_details']['mbw']['BR'] = 0;
  3972. $c['border_details']['mbw']['RT'] = 0;
  3973. $c['border_details']['mbw']['RB'] = 0;
  3974. $c['border_details']['mbw']['TL'] = 0;
  3975. $c['border_details']['mbw']['TR'] = 0;
  3976. $c['border_details']['mbw']['LT'] = 0;
  3977. $c['border_details']['mbw']['LB'] = 0;
  3978. $c['border_details']['R']['style'] = '';
  3979. $c['border_details']['L']['style'] = '';
  3980. $c['border_details']['T']['style'] = '';
  3981. $c['border_details']['B']['style'] = '';
  3982. $c['border_details']['R']['s'] = 0;
  3983. $c['border_details']['L']['s'] = 0;
  3984. $c['border_details']['T']['s'] = 0;
  3985. $c['border_details']['B']['s'] = 0;
  3986. $c['border_details']['R']['c'] = $this->mpdf->ConvertColor(0);
  3987. $c['border_details']['L']['c'] = $this->mpdf->ConvertColor(0);
  3988. $c['border_details']['T']['c'] = $this->mpdf->ConvertColor(0);
  3989. $c['border_details']['B']['c'] = $this->mpdf->ConvertColor(0);
  3990. $c['border_details']['R']['dom'] = 0;
  3991. $c['border_details']['L']['dom'] = 0;
  3992. $c['border_details']['T']['dom'] = 0;
  3993. $c['border_details']['B']['dom'] = 0;
  3994. $c['border_details']['cellposdom'] = 0;
  3995. }
  3996. if ($table['va']) {
  3997. $c['va'] = $table['va'];
  3998. }
  3999. if ($table['txta']) {
  4000. $c['a'] = $table['txta'];
  4001. }
  4002. if ($this->mpdf->table_border_attr_set) {
  4003. if ($table['border_details']) {
  4004. if (!$this->mpdf->simpleTables) {
  4005. $c['border_details']['R'] = $table['border_details']['R'];
  4006. $c['border_details']['L'] = $table['border_details']['L'];
  4007. $c['border_details']['T'] = $table['border_details']['T'];
  4008. $c['border_details']['B'] = $table['border_details']['B'];
  4009. $c['border'] = $table['border'];
  4010. $c['border_details']['L']['dom'] = 1;
  4011. $c['border_details']['R']['dom'] = 1;
  4012. $c['border_details']['T']['dom'] = 1;
  4013. $c['border_details']['B']['dom'] = 1;
  4014. } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
  4015. $table['simple']['border_details']['R'] = $table['border_details']['R'];
  4016. $table['simple']['border_details']['L'] = $table['border_details']['L'];
  4017. $table['simple']['border_details']['T'] = $table['border_details']['T'];
  4018. $table['simple']['border_details']['B'] = $table['border_details']['B'];
  4019. $table['simple']['border'] = $table['border'];
  4020. }
  4021. }
  4022. }
  4023. // INHERITED THEAD CSS Properties
  4024. if ($this->mpdf->tablethead) {
  4025. if ($this->mpdf->thead_valign_default)
  4026. $c['va'] = $align[strtolower($this->mpdf->thead_valign_default)];
  4027. if ($this->mpdf->thead_textalign_default)
  4028. $c['a'] = $align[strtolower($this->mpdf->thead_textalign_default)];
  4029. if ($this->mpdf->thead_font_weight == 'B') {
  4030. $this->mpdf->SetStyle('B', true);
  4031. }
  4032. if ($this->mpdf->thead_font_style == 'I') {
  4033. $this->mpdf->SetStyle('I', true);
  4034. }
  4035. if ($this->mpdf->thead_font_smCaps == 'S') {
  4036. $this->mpdf->textvar = ($this->mpdf->textvar | FC_SMALLCAPS);
  4037. } // mPDF 5.7.1
  4038. }
  4039. // INHERITED TFOOT CSS Properties
  4040. if ($this->mpdf->tabletfoot) {
  4041. if ($this->mpdf->tfoot_valign_default)
  4042. $c['va'] = $align[strtolower($this->mpdf->tfoot_valign_default)];
  4043. if ($this->mpdf->tfoot_textalign_default)
  4044. $c['a'] = $align[strtolower($this->mpdf->tfoot_textalign_default)];
  4045. if ($this->mpdf->tfoot_font_weight == 'B') {
  4046. $this->mpdf->SetStyle('B', true);
  4047. }
  4048. if ($this->mpdf->tfoot_font_style == 'I') {
  4049. $this->mpdf->SetStyle('I', true);
  4050. }
  4051. if ($this->mpdf->tfoot_font_style == 'S') {
  4052. $this->mpdf->textvar = ($this->mpdf->textvar | FC_SMALLCAPS);
  4053. } // mPDF 5.7.1
  4054. }
  4055. if ($this->mpdf->trow_text_rotate) {
  4056. $c['R'] = $this->mpdf->trow_text_rotate;
  4057. }
  4058. $this->mpdf->cell_border_dominance_L = 0;
  4059. $this->mpdf->cell_border_dominance_R = 0;
  4060. $this->mpdf->cell_border_dominance_T = 0;
  4061. $this->mpdf->cell_border_dominance_B = 0;
  4062. $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
  4063. $properties = $this->mpdf->cssmgr->array_merge_recursive_unique($this->mpdf->base_table_properties, $properties);
  4064. $this->mpdf->Reset(); // mPDF 6 ?????????????????????
  4065. $this->mpdf->setCSS($properties, 'TABLECELL', $tag);
  4066. $c['dfs'] = $this->mpdf->FontSize; // Default Font size
  4067. if (isset($properties['BACKGROUND-COLOR'])) {
  4068. $c['bgcolor'] = $properties['BACKGROUND-COLOR'];
  4069. } else if (isset($properties['BACKGROUND'])) {
  4070. $c['bgcolor'] = $properties['BACKGROUND'];
  4071. } else if (isset($attr['BGCOLOR']))
  4072. $c['bgcolor'] = $attr['BGCOLOR'];
  4073. /* -- BACKGROUNDS -- */
  4074. if (isset($properties['BACKGROUND-GRADIENT'])) {
  4075. $c['gradient'] = $properties['BACKGROUND-GRADIENT'];
  4076. } else {
  4077. $c['gradient'] = false;
  4078. }
  4079. if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->keep_block_together) {
  4080. $ret = $this->mpdf->SetBackground($properties, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
  4081. if ($ret) {
  4082. $c['background-image'] = $ret;
  4083. }
  4084. }
  4085. /* -- END BACKGROUNDS -- */
  4086. if (isset($properties['VERTICAL-ALIGN'])) {
  4087. $c['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
  4088. } else if (isset($attr['VALIGN']))
  4089. $c['va'] = $align[strtolower($attr['VALIGN'])];
  4090. if (isset($properties['TEXT-ALIGN']) && $properties['TEXT-ALIGN']) {
  4091. if (substr($properties['TEXT-ALIGN'], 0, 1) == 'D') {
  4092. $c['a'] = $properties['TEXT-ALIGN'];
  4093. } else {
  4094. $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])];
  4095. }
  4096. }
  4097. if (isset($attr['ALIGN']) && $attr['ALIGN']) {
  4098. if (strtolower($attr['ALIGN']) == 'char') {
  4099. if (isset($attr['CHAR']) && $attr['CHAR']) {
  4100. $char = html_entity_decode($attr['CHAR']);
  4101. $char = strcode2utf($char);
  4102. $d = array_search($char, $this->mpdf->decimal_align);
  4103. if ($d !== false) {
  4104. $c['a'] = $d . 'R';
  4105. }
  4106. } else {
  4107. $c['a'] = 'DPR';
  4108. }
  4109. } else {
  4110. $c['a'] = $align[strtolower($attr['ALIGN'])];
  4111. }
  4112. }
  4113. // mPDF 6
  4114. $c['direction'] = $table['direction'];
  4115. if (isset($attr['DIR']) and $attr['DIR'] != '') {
  4116. $c['direction'] = strtolower($attr['DIR']);
  4117. }
  4118. if (isset($properties['DIRECTION'])) {
  4119. $c['direction'] = strtolower($properties['DIRECTION']);
  4120. }
  4121. if (!$c['a']) {
  4122. if (isset($c['direction']) && $c['direction'] == 'rtl') {
  4123. $c['a'] = 'R';
  4124. } else {
  4125. $c['a'] = 'L';
  4126. }
  4127. }
  4128. $c['cellLineHeight'] = $table['cellLineHeight'];
  4129. if (isset($properties['LINE-HEIGHT'])) {
  4130. $c['cellLineHeight'] = $this->mpdf->fixLineheight($properties['LINE-HEIGHT']);
  4131. }
  4132. $c['cellLineStackingStrategy'] = $table['cellLineStackingStrategy'];
  4133. if (isset($properties['LINE-STACKING-STRATEGY'])) {
  4134. $c['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']);
  4135. }
  4136. $c['cellLineStackingShift'] = $table['cellLineStackingShift'];
  4137. if (isset($properties['LINE-STACKING-SHIFT'])) {
  4138. $c['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']);
  4139. }
  4140. if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE'] === "0")) {
  4141. $c['R'] = $properties['TEXT-ROTATE'];
  4142. }
  4143. if (isset($properties['BORDER'])) {
  4144. $bord = $this->mpdf->border_details($properties['BORDER']);
  4145. if ($bord['s']) {
  4146. if (!$this->mpdf->simpleTables) {
  4147. $c['border'] = _BORDER_ALL;
  4148. $c['border_details']['R'] = $bord;
  4149. $c['border_details']['L'] = $bord;
  4150. $c['border_details']['T'] = $bord;
  4151. $c['border_details']['B'] = $bord;
  4152. $c['border_details']['L']['dom'] = $this->mpdf->cell_border_dominance_L;
  4153. $c['border_details']['R']['dom'] = $this->mpdf->cell_border_dominance_R;
  4154. $c['border_details']['T']['dom'] = $this->mpdf->cell_border_dominance_T;
  4155. $c['border_details']['B']['dom'] = $this->mpdf->cell_border_dominance_B;
  4156. } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
  4157. $table['simple']['border'] = _BORDER_ALL;
  4158. $table['simple']['border_details']['R'] = $bord;
  4159. $table['simple']['border_details']['L'] = $bord;
  4160. $table['simple']['border_details']['T'] = $bord;
  4161. $table['simple']['border_details']['B'] = $bord;
  4162. }
  4163. }
  4164. }
  4165. if (!$this->mpdf->simpleTables) {
  4166. if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
  4167. $c['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
  4168. $this->mpdf->setBorder($c['border'], _BORDER_RIGHT, $c['border_details']['R']['s']);
  4169. $c['border_details']['R']['dom'] = $this->mpdf->cell_border_dominance_R;
  4170. }
  4171. if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
  4172. $c['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
  4173. $this->mpdf->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
  4174. $c['border_details']['L']['dom'] = $this->mpdf->cell_border_dominance_L;
  4175. }
  4176. if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
  4177. $c['border_details']['B'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
  4178. $this->mpdf->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
  4179. $c['border_details']['B']['dom'] = $this->mpdf->cell_border_dominance_B;
  4180. }
  4181. if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
  4182. $c['border_details']['T'] = $this->mpdf->border_details($properties['BORDER-TOP']);
  4183. $this->mpdf->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
  4184. $c['border_details']['T']['dom'] = $this->mpdf->cell_border_dominance_T;
  4185. }
  4186. } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
  4187. if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
  4188. $bord = $this->mpdf->border_details($properties['BORDER-LEFT']);
  4189. if ($bord['s']) {
  4190. $table['simple']['border'] = _BORDER_ALL;
  4191. } else {
  4192. $table['simple']['border'] = 0;
  4193. }
  4194. $table['simple']['border_details']['R'] = $bord;
  4195. $table['simple']['border_details']['L'] = $bord;
  4196. $table['simple']['border_details']['T'] = $bord;
  4197. $table['simple']['border_details']['B'] = $bord;
  4198. }
  4199. }
  4200. if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0 && !$table['borders_separate'] && $table['simple']['border']) {
  4201. $table['border_details'] = $table['simple']['border_details'];
  4202. $table['border'] = $table['simple']['border'];
  4203. }
  4204. // Border set on TR (if collapsed only)
  4205. if (!$table['borders_separate'] && !$this->mpdf->simpleTables && isset($table['trborder-left'][$this->mpdf->row])) {
  4206. if ($this->mpdf->col == 0) {
  4207. $left = $this->mpdf->border_details($table['trborder-left'][$this->mpdf->row]);
  4208. $c['border_details']['L'] = $left;
  4209. $this->mpdf->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
  4210. }
  4211. $c['border_details']['B'] = $this->mpdf->border_details($table['trborder-bottom'][$this->mpdf->row]);
  4212. $this->mpdf->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
  4213. $c['border_details']['T'] = $this->mpdf->border_details($table['trborder-top'][$this->mpdf->row]);
  4214. $this->mpdf->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
  4215. }
  4216. if ($this->mpdf->packTableData && !$this->mpdf->simpleTables) {
  4217. $c['borderbin'] = $this->mpdf->_packCellBorder($c);
  4218. unset($c['border']);
  4219. unset($c['border_details']);
  4220. }
  4221. if (isset($properties['PADDING-LEFT'])) {
  4222. $c['padding']['L'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4223. }
  4224. if (isset($properties['PADDING-RIGHT'])) {
  4225. $c['padding']['R'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4226. }
  4227. if (isset($properties['PADDING-BOTTOM'])) {
  4228. $c['padding']['B'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4229. }
  4230. if (isset($properties['PADDING-TOP'])) {
  4231. $c['padding']['T'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4232. }
  4233. $w = '';
  4234. if (isset($properties['WIDTH'])) {
  4235. $w = $properties['WIDTH'];
  4236. } else if (isset($attr['WIDTH'])) {
  4237. $w = $attr['WIDTH'];
  4238. }
  4239. if ($w) {
  4240. if (strpos($w, '%') && !$this->mpdf->ignore_table_percents) {
  4241. $c['wpercent'] = $w + 0;
  4242. } // makes 80% -> 80
  4243. else if (!strpos($w, '%') && !$this->mpdf->ignore_table_widths) {
  4244. $c['w'] = $this->mpdf->ConvertSize($w, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4245. }
  4246. }
  4247. if (isset($properties['HEIGHT']) && !strpos($properties['HEIGHT'], '%')) {
  4248. $c['h'] = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4249. } else if (isset($attr['HEIGHT']) && !strpos($attr['HEIGHT'], '%'))
  4250. $c['h'] = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
  4251. if (isset($properties['WHITE-SPACE'])) {
  4252. if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') {
  4253. $c['nowrap'] = 1;
  4254. }
  4255. }
  4256. $properties = array();
  4257. if (isset($attr['TEXT-ROTATE'])) {
  4258. $c['R'] = $attr['TEXT-ROTATE'];
  4259. }
  4260. if (isset($attr['NOWRAP']) && $attr['NOWRAP'])
  4261. $c['nowrap'] = 1;
  4262. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col] = $c;
  4263. unset($c);
  4264. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0;
  4265. $cs = $rs = 1;
  4266. if (isset($attr['COLSPAN']) && $attr['COLSPAN'] > 1)
  4267. $cs = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['colspan'] = $attr['COLSPAN'];
  4268. if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] < $this->mpdf->col + $cs) {
  4269. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] = $this->mpdf->col + $cs;
  4270. } // following code moved outside if...
  4271. for ($l = $this->mpdf->col; $l < $this->mpdf->col + $cs; $l++) {
  4272. if ($l - $this->mpdf->col)
  4273. $this->mpdf->cell[$this->mpdf->row][$l] = 0;
  4274. }
  4275. if (isset($attr['ROWSPAN']) && $attr['ROWSPAN'] > 1)
  4276. $rs = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['rowspan'] = $attr['ROWSPAN'];
  4277. for ($k = $this->mpdf->row; $k < $this->mpdf->row + $rs; $k++) {
  4278. for ($l = $this->mpdf->col; $l < $this->mpdf->col + $cs; $l++) {
  4279. if ($k - $this->mpdf->row || $l - $this->mpdf->col)
  4280. $this->mpdf->cell[$k][$l] = 0;
  4281. }
  4282. }
  4283. unset($table);
  4284. break;
  4285. /* -- END TABLES -- */
  4286. }//end of switch
  4287. }
  4288. function CloseTag($tag, &$ahtml, &$ihtml)
  4289. { // mPDF 6
  4290. //Closing tag
  4291. if ($tag == 'OPTION') {
  4292. $this->mpdf->selectoption['ACTIVE'] = false;
  4293. $this->mpdf->lastoptionaltag = '';
  4294. }
  4295. if ($tag == 'TTS' or $tag == 'TTA' or $tag == 'TTZ') {
  4296. if ($this->mpdf->InlineProperties[$tag]) {
  4297. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  4298. }
  4299. unset($this->mpdf->InlineProperties[$tag]);
  4300. $ltag = strtolower($tag);
  4301. $this->mpdf->$ltag = false;
  4302. }
  4303. if ($tag == 'FONT' || $tag == 'SPAN' || $tag == 'CODE' || $tag == 'KBD' || $tag == 'SAMP' || $tag == 'TT' || $tag == 'VAR' || $tag == 'INS' || $tag == 'STRONG' || $tag == 'CITE' || $tag == 'SUB' || $tag == 'SUP' || $tag == 'S' || $tag == 'STRIKE' || $tag == 'DEL' || $tag == 'Q' || $tag == 'EM' || $tag == 'B' || $tag == 'I' || $tag == 'U' | $tag == 'SMALL' || $tag == 'BIG' || $tag == 'ACRONYM' || $tag == 'MARK' || $tag == 'TIME' || $tag == 'PROGRESS' || $tag == 'METER' || $tag == 'BDO' || $tag == 'BDI'
  4304. ) {
  4305. $annot = false; // mPDF 6
  4306. $bdf = false; // mPDF 6
  4307. // mPDF 5.7.3 Inline tags
  4308. if ($tag == 'PROGRESS' || $tag == 'METER') {
  4309. if (isset($this->mpdf->InlineProperties[$tag]) && $this->mpdf->InlineProperties[$tag]) {
  4310. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  4311. }
  4312. unset($this->mpdf->InlineProperties[$tag]);
  4313. if (isset($this->mpdf->InlineAnnots[$tag]) && $this->mpdf->InlineAnnots[$tag]) {
  4314. $annot = $this->mpdf->InlineAnnots[$tag];
  4315. } // *ANNOTATIONS*
  4316. unset($this->mpdf->InlineAnnots[$tag]); // *ANNOTATIONS*
  4317. } else {
  4318. if (isset($this->mpdf->InlineProperties[$tag]) && count($this->mpdf->InlineProperties[$tag])) {
  4319. $tmpProps = array_pop($this->mpdf->InlineProperties[$tag]); // mPDF 5.7.4
  4320. $this->mpdf->restoreInlineProperties($tmpProps);
  4321. }
  4322. if (isset($this->mpdf->InlineAnnots[$tag]) && count($this->mpdf->InlineAnnots[$tag])) { // *ANNOTATIONS*
  4323. $annot = array_pop($this->mpdf->InlineAnnots[$tag]); // *ANNOTATIONS*
  4324. } // *ANNOTATIONS*
  4325. if (isset($this->mpdf->InlineBDF[$tag]) && count($this->mpdf->InlineBDF[$tag])) { // mPDF 6
  4326. $bdfarr = array_pop($this->mpdf->InlineBDF[$tag]);
  4327. $bdf = $bdfarr[0];
  4328. }
  4329. }
  4330. /* -- ANNOTATIONS -- */
  4331. if ($annot) { // mPDF 6
  4332. if ($this->mpdf->tableLevel) { // *TABLES*
  4333. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($annot); // *TABLES*
  4334. } // *TABLES*
  4335. else { // *TABLES*
  4336. $this->mpdf->textbuffer[] = array($annot);
  4337. } // *TABLES*
  4338. }
  4339. /* -- END ANNOTATIONS -- */
  4340. // mPDF 6 bidi
  4341. // mPDF 6 Bidirectional formatting for inline elements
  4342. if ($bdf) {
  4343. $popf = $this->mpdf->_setBidiCodes('end', $bdf);
  4344. $this->mpdf->OTLdata = array();
  4345. if ($this->mpdf->tableLevel) {
  4346. $this->mpdf->_saveCellTextBuffer($popf);
  4347. } else {
  4348. $this->mpdf->_saveTextBuffer($popf);
  4349. }
  4350. }
  4351. } // End of (most) Inline elements eg SPAN
  4352. if ($tag == 'METER' || $tag == 'PROGRESS') {
  4353. $this->mpdf->ignorefollowingspaces = false;
  4354. $this->mpdf->inMeter = false;
  4355. }
  4356. if ($tag == 'A') {
  4357. $this->mpdf->HREF = '';
  4358. if (isset($this->mpdf->InlineProperties['A'])) {
  4359. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['A']);
  4360. }
  4361. unset($this->mpdf->InlineProperties['A']);
  4362. }
  4363. if ($tag == 'LEGEND') {
  4364. if (count($this->mpdf->textbuffer) && !$this->mpdf->tableLevel) {
  4365. $leg = $this->mpdf->textbuffer[(count($this->mpdf->textbuffer) - 1)];
  4366. unset($this->mpdf->textbuffer[(count($this->mpdf->textbuffer) - 1)]);
  4367. $this->mpdf->textbuffer = array_values($this->mpdf->textbuffer);
  4368. $this->mpdf->blk[$this->mpdf->blklvl]['border_legend'] = $leg;
  4369. $this->mpdf->blk[$this->mpdf->blklvl]['margin_top'] += ($leg[11] / 2) / _MPDFK;
  4370. $this->mpdf->blk[$this->mpdf->blklvl]['padding_top'] += ($leg[11] / 2) / _MPDFK;
  4371. }
  4372. if (isset($this->mpdf->InlineProperties['LEGEND'])) {
  4373. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['LEGEND']);
  4374. }
  4375. unset($this->mpdf->InlineProperties['LEGEND']);
  4376. $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
  4377. }
  4378. /* -- FORMS -- */
  4379. // *********** FORM ELEMENTS ********************
  4380. if ($tag == 'TEXTAREA') {
  4381. $this->mpdf->ignorefollowingspaces = false;
  4382. $this->mpdf->specialcontent = '';
  4383. if ($this->mpdf->InlineProperties[$tag]) {
  4384. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  4385. }
  4386. unset($this->mpdf->InlineProperties[$tag]);
  4387. }
  4388. if ($tag == 'SELECT') {
  4389. $this->mpdf->ignorefollowingspaces = false;
  4390. $this->mpdf->lastoptionaltag = '';
  4391. $texto = '';
  4392. $OTLdata = false;
  4393. if (isset($this->mpdf->selectoption['SELECTED'])) {
  4394. $texto = $this->mpdf->selectoption['SELECTED'];
  4395. }
  4396. if (isset($this->mpdf->selectoption['SELECTED-OTLDATA'])) {
  4397. $OTLdata = $this->mpdf->selectoption['SELECTED-OTLDATA'];
  4398. }
  4399. if ($this->mpdf->useActiveForms) {
  4400. $w = $this->mpdf->selectoption['MAXWIDTH'];
  4401. } else {
  4402. $w = $this->mpdf->GetStringWidth($texto, true, $OTLdata);
  4403. }
  4404. if ($w == 0) {
  4405. $w = 5;
  4406. }
  4407. $objattr['type'] = 'select';
  4408. $objattr['text'] = $texto;
  4409. $objattr['OTLdata'] = $OTLdata;
  4410. if (isset($this->mpdf->selectoption['NAME'])) {
  4411. $objattr['fieldname'] = $this->mpdf->selectoption['NAME'];
  4412. }
  4413. if (isset($this->mpdf->selectoption['READONLY'])) {
  4414. $objattr['readonly'] = true;
  4415. }
  4416. if (isset($this->mpdf->selectoption['REQUIRED'])) {
  4417. $objattr['required'] = true;
  4418. }
  4419. if (isset($this->mpdf->selectoption['SPELLCHECK'])) {
  4420. $objattr['spellcheck'] = true;
  4421. }
  4422. if (isset($this->mpdf->selectoption['EDITABLE'])) {
  4423. $objattr['editable'] = true;
  4424. }
  4425. if (isset($this->mpdf->selectoption['ONCHANGE'])) {
  4426. $objattr['onChange'] = $this->mpdf->selectoption['ONCHANGE'];
  4427. }
  4428. if (isset($this->mpdf->selectoption['ITEMS'])) {
  4429. $objattr['items'] = $this->mpdf->selectoption['ITEMS'];
  4430. }
  4431. if (isset($this->mpdf->selectoption['MULTIPLE'])) {
  4432. $objattr['multiple'] = $this->mpdf->selectoption['MULTIPLE'];
  4433. }
  4434. if (isset($this->mpdf->selectoption['DISABLED'])) {
  4435. $objattr['disabled'] = $this->mpdf->selectoption['DISABLED'];
  4436. }
  4437. if (isset($this->mpdf->selectoption['TITLE'])) {
  4438. $objattr['title'] = $this->mpdf->selectoption['TITLE'];
  4439. }
  4440. if (isset($this->mpdf->selectoption['COLOR'])) {
  4441. $objattr['color'] = $this->mpdf->selectoption['COLOR'];
  4442. }
  4443. if (isset($this->mpdf->selectoption['SIZE'])) {
  4444. $objattr['size'] = $this->mpdf->selectoption['SIZE'];
  4445. }
  4446. if (isset($objattr['size']) && $objattr['size'] > 1) {
  4447. $rows = $objattr['size'];
  4448. } else {
  4449. $rows = 1;
  4450. }
  4451. $objattr['fontfamily'] = $this->mpdf->FontFamily;
  4452. $objattr['fontsize'] = $this->mpdf->FontSizePt;
  4453. $objattr['width'] = $w + ($this->mpdf->mpdfform->form_element_spacing['select']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['select']['inner']['h'] * 2) + ($this->mpdf->FontSize * 1.4);
  4454. $objattr['height'] = ($this->mpdf->FontSize * $rows) + ($this->mpdf->mpdfform->form_element_spacing['select']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['select']['inner']['v'] * 2);
  4455. $e = "\xbb\xa4\xactype=select,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  4456. // Clear properties - tidy up
  4457. $properties = array();
  4458. // Output it to buffers
  4459. if ($this->mpdf->tableLevel) { // *TABLES*
  4460. $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
  4461. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; // *TABLES*
  4462. } // *TABLES*
  4463. else { // *TABLES*
  4464. $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
  4465. } // *TABLES*
  4466. $this->mpdf->selectoption = array();
  4467. $this->mpdf->specialcontent = '';
  4468. if ($this->mpdf->InlineProperties[$tag]) {
  4469. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
  4470. }
  4471. unset($this->mpdf->InlineProperties[$tag]);
  4472. }
  4473. /* -- END FORMS -- */
  4474. // *********** BLOCKS ********************
  4475. // mPDF 6 Lists
  4476. if ($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'PRE' || $tag == 'FORM' || $tag == 'ADDRESS' || $tag == 'BLOCKQUOTE' || $tag == 'CENTER' || $tag == 'DT' || $tag == 'DD' || $tag == 'DL' || $tag == 'CAPTION' || $tag == 'FIELDSET' || $tag == 'UL' || $tag == 'OL' || $tag == 'LI' || $tag == 'ARTICLE' || $tag == 'ASIDE' || $tag == 'FIGURE' || $tag == 'FIGCAPTION' || $tag == 'FOOTER' || $tag == 'HEADER' || $tag == 'HGROUP' || $tag == 'MAIN' || $tag == 'NAV' || $tag == 'SECTION' || $tag == 'DETAILS' || $tag == 'SUMMARY'
  4477. ) {
  4478. // mPDF 6 bidi
  4479. // Block
  4480. // If unicode-bidi set, any embedding levels, isolates, or overrides started by this box are closed
  4481. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
  4482. $blockpost = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
  4483. if ($blockpost) {
  4484. $this->mpdf->OTLdata = array();
  4485. if ($this->mpdf->tableLevel) {
  4486. $this->mpdf->_saveCellTextBuffer($blockpost);
  4487. } else {
  4488. $this->mpdf->_saveTextBuffer($blockpost);
  4489. }
  4490. }
  4491. }
  4492. $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
  4493. $this->mpdf->blockjustfinished = true;
  4494. $this->mpdf->lastblockbottommargin = $this->mpdf->blk[$this->mpdf->blklvl]['margin_bottom'];
  4495. // mPDF 6 Lists
  4496. if ($tag == 'UL' || $tag == 'OL') {
  4497. if ($this->mpdf->listlvl > 0 && $this->mpdf->tableLevel) {
  4498. if (isset($this->mpdf->listtype[$this->mpdf->listlvl]))
  4499. unset($this->mpdf->listtype[$this->mpdf->listlvl]);
  4500. }
  4501. $this->mpdf->listlvl--;
  4502. $this->mpdf->listitem = array();
  4503. }
  4504. if ($tag == 'LI') {
  4505. $this->mpdf->listitem = array();
  4506. }
  4507. if (preg_match('/^H\d/', $tag) && !$this->mpdf->tableLevel && !$this->mpdf->writingToC) {
  4508. if (isset($this->mpdf->h2toc[$tag]) || isset($this->mpdf->h2bookmarks[$tag])) {
  4509. $content = '';
  4510. if (count($this->mpdf->textbuffer) == 1) {
  4511. $content = $this->mpdf->textbuffer[0][0];
  4512. } else {
  4513. for ($i = 0; $i < count($this->mpdf->textbuffer); $i++) {
  4514. if (substr($this->mpdf->textbuffer[$i][0], 0, 3) != "\xbb\xa4\xac") { //inline object
  4515. $content .= $this->mpdf->textbuffer[$i][0];
  4516. }
  4517. }
  4518. }
  4519. /* -- TOC -- */
  4520. if (isset($this->mpdf->h2toc[$tag])) {
  4521. $objattr = array();
  4522. $objattr['type'] = 'toc';
  4523. $objattr['toclevel'] = $this->mpdf->h2toc[$tag];
  4524. $objattr['CONTENT'] = htmlspecialchars($content);
  4525. $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  4526. array_unshift($this->mpdf->textbuffer, array($e));
  4527. }
  4528. /* -- END TOC -- */
  4529. /* -- BOOKMARKS -- */
  4530. if (isset($this->mpdf->h2bookmarks[$tag])) {
  4531. $objattr = array();
  4532. $objattr['type'] = 'bookmark';
  4533. $objattr['bklevel'] = $this->mpdf->h2bookmarks[$tag];
  4534. $objattr['CONTENT'] = $content;
  4535. $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  4536. array_unshift($this->mpdf->textbuffer, array($e));
  4537. }
  4538. /* -- END BOOKMARKS -- */
  4539. }
  4540. }
  4541. /* -- TABLES -- */
  4542. if ($this->mpdf->tableLevel) {
  4543. if ($this->mpdf->linebreakjustfinished) {
  4544. $this->mpdf->blockjustfinished = false;
  4545. }
  4546. if (isset($this->mpdf->InlineProperties['BLOCKINTABLE'])) {
  4547. if ($this->mpdf->InlineProperties['BLOCKINTABLE']) {
  4548. $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['BLOCKINTABLE']);
  4549. }
  4550. unset($this->mpdf->InlineProperties['BLOCKINTABLE']);
  4551. }
  4552. if ($tag == 'PRE') {
  4553. $this->mpdf->ispre = false;
  4554. }
  4555. return;
  4556. }
  4557. /* -- END TABLES -- */
  4558. $this->mpdf->lastoptionaltag = '';
  4559. $this->mpdf->divbegin = false;
  4560. $this->mpdf->linebreakjustfinished = false;
  4561. $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
  4562. /* -- CSS-FLOAT -- */
  4563. // If float contained in a float, need to extend bottom to allow for it
  4564. $currpos = $this->mpdf->page * 1000 + $this->mpdf->y;
  4565. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos']) && $this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] > $currpos) {
  4566. $old_page = $this->mpdf->page;
  4567. $new_page = intval($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] / 1000);
  4568. if ($old_page != $new_page) {
  4569. $s = $this->mpdf->PrintPageBackgrounds();
  4570. // Writes after the marker so not overwritten later by page background etc.
  4571. $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
  4572. $this->mpdf->pageBackgrounds = array();
  4573. $this->mpdf->page = $new_page;
  4574. $this->mpdf->ResetMargins();
  4575. $this->mpdf->Reset();
  4576. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4577. }
  4578. $this->mpdf->y = (($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] * 1000) % 1000000) / 1000; // mod changes operands to integers before processing
  4579. }
  4580. /* -- END CSS-FLOAT -- */
  4581. //Print content
  4582. if ($this->mpdf->lastblocklevelchange == 1) {
  4583. $blockstate = 3;
  4584. } // Top & bottom margins/padding
  4585. else if ($this->mpdf->lastblocklevelchange == -1) {
  4586. $blockstate = 2;
  4587. } // Bottom margins/padding only
  4588. else {
  4589. $blockstate = 0;
  4590. }
  4591. // called from after e.g. </table> </div> </div> ... Outputs block margin/border and padding
  4592. if (count($this->mpdf->textbuffer) && $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1]) {
  4593. if (substr($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], 0, 3) != "\xbb\xa4\xac") { // not special content
  4594. // Right trim last content and adjust OTLdata
  4595. if (preg_match('/[ ]+$/', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], $m)) {
  4596. $strip = strlen($m[0]);
  4597. $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = substr($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], 0, (strlen($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]) - $strip));
  4598. /* -- OTL -- */
  4599. if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
  4600. $this->mpdf->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false, true); // mPDF 6 ZZZ99K
  4601. }
  4602. /* -- END OTL -- */
  4603. }
  4604. }
  4605. }
  4606. if (count($this->mpdf->textbuffer) == 0 && $this->mpdf->lastblocklevelchange != 0) {
  4607. //$this->mpdf->newFlowingBlock( $this->mpdf->blk[$this->mpdf->blklvl]['width'],$this->mpdf->lineheight,'',false,2,true, (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr'));
  4608. $this->mpdf->newFlowingBlock($this->mpdf->blk[$this->mpdf->blklvl]['width'], $this->mpdf->lineheight, '', false, $blockstate, true, (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr'));
  4609. $this->mpdf->finishFlowingBlock(true); // true = END of flowing block
  4610. $this->mpdf->PaintDivBB('', $blockstate);
  4611. } else {
  4612. $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
  4613. }
  4614. $this->mpdf->textbuffer = array();
  4615. if ($this->mpdf->kwt) {
  4616. $this->mpdf->kwt_height = $this->mpdf->y - $this->mpdf->kwt_y0;
  4617. }
  4618. /* -- CSS-IMAGE-FLOAT -- */
  4619. $this->mpdf->printfloatbuffer();
  4620. /* -- END CSS-IMAGE-FLOAT -- */
  4621. if ($tag == 'PRE') {
  4622. $this->mpdf->ispre = false;
  4623. }
  4624. /* -- CSS-FLOAT -- */
  4625. if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] == 'R') {
  4626. // If width not set, here would need to adjust and output buffer
  4627. $s = $this->mpdf->PrintPageBackgrounds();
  4628. // Writes after the marker so not overwritten later by page background etc.
  4629. $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
  4630. $this->mpdf->pageBackgrounds = array();
  4631. $this->mpdf->Reset();
  4632. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4633. for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
  4634. if (isset($this->mpdf->blk[$i]['float_endpos'])) {
  4635. $this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], ($this->mpdf->page * 1000 + $this->mpdf->y));
  4636. } else {
  4637. $this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
  4638. }
  4639. }
  4640. $this->mpdf->floatDivs[] = array(
  4641. 'side' => 'R',
  4642. 'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
  4643. 'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
  4644. 'startpos' => ($this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y']),
  4645. 'endpage' => $this->mpdf->page,
  4646. 'y1' => $this->mpdf->y,
  4647. 'endpos' => ($this->mpdf->page * 1000 + $this->mpdf->y),
  4648. 'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
  4649. 'blklvl' => $this->mpdf->blklvl,
  4650. 'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
  4651. );
  4652. $this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
  4653. $this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
  4654. $this->mpdf->ResetMargins();
  4655. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4656. }
  4657. if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] == 'L') {
  4658. // If width not set, here would need to adjust and output buffer
  4659. $s = $this->mpdf->PrintPageBackgrounds();
  4660. // Writes after the marker so not overwritten later by page background etc.
  4661. $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
  4662. $this->mpdf->pageBackgrounds = array();
  4663. $this->mpdf->Reset();
  4664. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4665. for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
  4666. if (isset($this->mpdf->blk[$i]['float_endpos'])) {
  4667. $this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], ($this->mpdf->page * 1000 + $this->mpdf->y));
  4668. } else {
  4669. $this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
  4670. }
  4671. }
  4672. $this->mpdf->floatDivs[] = array(
  4673. 'side' => 'L',
  4674. 'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
  4675. 'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
  4676. 'startpos' => ($this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y']),
  4677. 'endpage' => $this->mpdf->page,
  4678. 'y1' => $this->mpdf->y,
  4679. 'endpos' => ($this->mpdf->page * 1000 + $this->mpdf->y),
  4680. 'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
  4681. 'blklvl' => $this->mpdf->blklvl,
  4682. 'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
  4683. );
  4684. $this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
  4685. $this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
  4686. $this->mpdf->ResetMargins();
  4687. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4688. }
  4689. /* -- END CSS-FLOAT -- */
  4690. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['visibility']) && $this->mpdf->blk[$this->mpdf->blklvl]['visibility'] != 'visible') {
  4691. $this->mpdf->SetVisibility('visible');
  4692. }
  4693. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'])) {
  4694. $page_break_after = $this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'];
  4695. } else {
  4696. $page_break_after = '';
  4697. }
  4698. //Reset values
  4699. $this->mpdf->Reset();
  4700. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['z-index']) && $this->mpdf->blk[$this->mpdf->blklvl]['z-index'] > 0) {
  4701. $this->mpdf->EndLayer();
  4702. }
  4703. // mPDF 6 page-break-inside:avoid
  4704. if ($this->mpdf->blk[$this->mpdf->blklvl]['keep_block_together']) {
  4705. $movepage = false;
  4706. // If page-break-inside:avoid section has broken to new page but fits on one side - then move:
  4707. if (($this->mpdf->page - $this->mpdf->kt_p00) == 1 && $this->mpdf->y < $this->mpdf->kt_y00) {
  4708. $movepage = true;
  4709. }
  4710. if (($this->mpdf->page - $this->mpdf->kt_p00) > 0) {
  4711. for ($i = $this->mpdf->page; $i > $this->mpdf->kt_p00; $i--) {
  4712. unset($this->mpdf->pages[$i]);
  4713. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i])) {
  4714. unset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i]);
  4715. }
  4716. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i])) {
  4717. unset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i]);
  4718. }
  4719. if (isset($this->mpdf->pageoutput[$i])) {
  4720. unset($this->mpdf->pageoutput[$i]);
  4721. }
  4722. }
  4723. $this->mpdf->page = $this->mpdf->kt_p00;
  4724. }
  4725. $this->mpdf->keep_block_together = 0;
  4726. $this->mpdf->pageoutput[$this->mpdf->page] = array();
  4727. $this->mpdf->y = $this->mpdf->kt_y00;
  4728. $ihtml = $this->mpdf->blk[$this->mpdf->blklvl]['array_i'] - 1;
  4729. $ahtml[$ihtml + 1] .= ' pagebreakavoidchecked="true";'; // avoid re-iterating; read in OpenTag()
  4730. unset($this->mpdf->blk[$this->mpdf->blklvl]);
  4731. $this->mpdf->blklvl--;
  4732. for ($blklvl = 1; $blklvl <= $this->mpdf->blklvl; $blklvl++) {
  4733. $this->mpdf->blk[$blklvl]['y0'] = $this->mpdf->blk[$blklvl]['initial_y0'];
  4734. $this->mpdf->blk[$blklvl]['x0'] = $this->mpdf->blk[$blklvl]['initial_x0'];
  4735. $this->mpdf->blk[$blklvl]['startpage'] = $this->mpdf->blk[$blklvl]['initial_startpage'];
  4736. }
  4737. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['x0'])) {
  4738. $this->mpdf->x = $this->mpdf->blk[$this->mpdf->blklvl]['x0'];
  4739. } else {
  4740. $this->mpdf->x = $this->mpdf->lMargin;
  4741. }
  4742. $this->mpdf->lastblocklevelchange = 0;
  4743. $this->mpdf->ResetMargins();
  4744. if ($movepage) {
  4745. $this->mpdf->AddPage();
  4746. }
  4747. return;
  4748. }
  4749. if ($this->mpdf->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
  4750. if ($this->mpdf->blk[$this->mpdf->blklvl]['tag'] == $tag) {
  4751. unset($this->mpdf->blk[$this->mpdf->blklvl]);
  4752. $this->mpdf->blklvl--;
  4753. }
  4754. //else { echo $tag; exit; } // debug - forces error if incorrectly nested html tags
  4755. }
  4756. $this->mpdf->lastblocklevelchange = -1;
  4757. // Reset Inline-type properties
  4758. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties'])) {
  4759. $this->mpdf->restoreInlineProperties($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']);
  4760. }
  4761. $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
  4762. if (!$this->mpdf->tableLevel && $page_break_after) {
  4763. $save_blklvl = $this->mpdf->blklvl;
  4764. $save_blk = $this->mpdf->blk;
  4765. $save_silp = $this->mpdf->saveInlineProperties();
  4766. $save_ilp = $this->mpdf->InlineProperties;
  4767. $save_bflp = $this->mpdf->InlineBDF;
  4768. $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
  4769. // mPDF 6 pagebreaktype
  4770. $startpage = $this->mpdf->page;
  4771. $pagebreaktype = $this->mpdf->defaultPagebreakType;
  4772. if ($this->mpdf->ColActive) {
  4773. $pagebreaktype = 'cloneall';
  4774. }
  4775. // mPDF 6 pagebreaktype
  4776. $this->mpdf->_preForcedPagebreak($pagebreaktype);
  4777. if ($page_break_after == 'RIGHT') {
  4778. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  4779. } else if ($page_break_after == 'LEFT') {
  4780. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  4781. } else {
  4782. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  4783. }
  4784. // mPDF 6 pagebreaktype
  4785. $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
  4786. $this->mpdf->InlineProperties = $save_ilp;
  4787. $this->mpdf->InlineBDF = $save_bflp;
  4788. $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
  4789. $this->mpdf->restoreInlineProperties($save_silp);
  4790. }
  4791. // mPDF 6 bidi
  4792. // Block
  4793. // If unicode-bidi set, any embedding levels, isolates, or overrides reopened in the continuing block
  4794. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
  4795. $blockpre = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
  4796. if ($blockpre) {
  4797. $this->mpdf->OTLdata = array();
  4798. if ($this->mpdf->tableLevel) {
  4799. $this->mpdf->_saveCellTextBuffer($blockpre);
  4800. } else {
  4801. $this->mpdf->_saveTextBuffer($blockpre);
  4802. }
  4803. }
  4804. }
  4805. }
  4806. /* -- TABLES -- */
  4807. if ($tag == 'TH')
  4808. $this->mpdf->SetStyle('B', false);
  4809. if (($tag == 'TH' or $tag == 'TD') && $this->mpdf->tableLevel) {
  4810. $this->mpdf->lastoptionaltag = 'TR';
  4811. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4812. $this->mpdf->cssmgr->tbCSSlvl--;
  4813. if (!$this->mpdf->tdbegin) {
  4814. return;
  4815. }
  4816. $this->mpdf->tdbegin = false;
  4817. // Added for correct calculation of cell column width - otherwise misses the last line if not end </p> etc.
  4818. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  4819. if (!is_array($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col])) {
  4820. throw new MpdfException("You may have an error in your HTML code e.g. &lt;/td&gt;&lt;/td&gt;");
  4821. }
  4822. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  4823. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  4824. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  4825. }
  4826. // Remove last <br> if at end of cell
  4827. if (isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'])) {
  4828. $ntb = count($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer']);
  4829. } else {
  4830. $ntb = 0;
  4831. }
  4832. if ($ntb > 1 && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][$ntb - 1][0] == "\n") {
  4833. unset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][$ntb - 1]);
  4834. }
  4835. if ($this->mpdf->tablethead) {
  4836. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'][$this->mpdf->row] = true;
  4837. if ($this->mpdf->tableLevel == 1) {
  4838. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows'] = max($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows'], ($this->mpdf->row + 1));
  4839. }
  4840. }
  4841. if ($this->mpdf->tabletfoot) {
  4842. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$this->mpdf->row] = true;
  4843. if ($this->mpdf->tableLevel == 1) {
  4844. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'] = max($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'], ($this->mpdf->row + 1 - $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows']));
  4845. }
  4846. }
  4847. $this->mpdf->Reset();
  4848. }
  4849. if ($tag == 'TR' && $this->mpdf->tableLevel) {
  4850. // If Border set on TR - Update right border
  4851. if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row])) {
  4852. $c = & $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col];
  4853. if ($c) {
  4854. if ($this->mpdf->packTableData) {
  4855. $cell = $this->mpdf->_unpackCellBorder($c['borderbin']);
  4856. } else {
  4857. $cell = $c;
  4858. }
  4859. $cell['border_details']['R'] = $this->mpdf->border_details($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row]);
  4860. $this->mpdf->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
  4861. if ($this->mpdf->packTableData) {
  4862. $c['borderbin'] = $this->mpdf->_packCellBorder($cell);
  4863. unset($c['border']);
  4864. unset($c['border_details']);
  4865. } else {
  4866. $c = $cell;
  4867. }
  4868. }
  4869. }
  4870. $this->mpdf->lastoptionaltag = '';
  4871. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4872. $this->mpdf->cssmgr->tbCSSlvl--;
  4873. $this->mpdf->trow_text_rotate = '';
  4874. $this->mpdf->tabletheadjustfinished = false;
  4875. }
  4876. if ($tag == 'TBODY') {
  4877. $this->mpdf->lastoptionaltag = '';
  4878. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4879. $this->mpdf->cssmgr->tbCSSlvl--;
  4880. }
  4881. if ($tag == 'THEAD') {
  4882. $this->mpdf->lastoptionaltag = '';
  4883. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4884. $this->mpdf->cssmgr->tbCSSlvl--;
  4885. $this->mpdf->tablethead = 0;
  4886. $this->mpdf->tabletheadjustfinished = true;
  4887. $this->mpdf->ResetStyles();
  4888. $this->mpdf->thead_font_weight = '';
  4889. $this->mpdf->thead_font_style = '';
  4890. $this->mpdf->thead_font_smCaps = '';
  4891. $this->mpdf->thead_valign_default = '';
  4892. $this->mpdf->thead_textalign_default = '';
  4893. }
  4894. if ($tag == 'TFOOT') {
  4895. $this->mpdf->lastoptionaltag = '';
  4896. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4897. $this->mpdf->cssmgr->tbCSSlvl--;
  4898. $this->mpdf->tabletfoot = 0;
  4899. $this->mpdf->ResetStyles();
  4900. $this->mpdf->tfoot_font_weight = '';
  4901. $this->mpdf->tfoot_font_style = '';
  4902. $this->mpdf->tfoot_font_smCaps = '';
  4903. $this->mpdf->tfoot_valign_default = '';
  4904. $this->mpdf->tfoot_textalign_default = '';
  4905. }
  4906. if ($tag == 'TABLE') { // TABLE-END (
  4907. if ($this->mpdf->progressBar) {
  4908. $this->mpdf->UpdateProgressBar(1, '', 'TABLE');
  4909. } // *PROGRESS-BAR*
  4910. if ($this->mpdf->progressBar) {
  4911. $this->mpdf->UpdateProgressBar(7, 0, '');
  4912. } // *PROGRESS-BAR*
  4913. $this->mpdf->lastoptionaltag = '';
  4914. unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
  4915. $this->mpdf->cssmgr->tbCSSlvl--;
  4916. $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
  4917. // mPDF 5.7.3
  4918. // In case a colspan (on a row after first row) exceeded number of columns in table
  4919. for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
  4920. for ($l = 0; $l < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc']; $l++) {
  4921. if (!isset($this->mpdf->cell[$k][$l])) {
  4922. for ($n = $l - 1; $n >= 0; $n--) {
  4923. if (isset($this->mpdf->cell[$k][$n]) && $this->mpdf->cell[$k][$n] != 0) {
  4924. break;
  4925. }
  4926. }
  4927. $this->mpdf->cell[$k][$l] = array(
  4928. 'a' => 'C',
  4929. 'va' => 'M',
  4930. 'R' => false,
  4931. 'nowrap' => false,
  4932. 'bgcolor' => false,
  4933. 'padding' => array('L' => false, 'R' => false, 'T' => false, 'B' => false),
  4934. 'gradient' => false,
  4935. 's' => 0,
  4936. 'maxs' => 0,
  4937. 'textbuffer' => array(),
  4938. 'dfs' => $this->mpdf->FontSize,
  4939. );
  4940. if (!$this->mpdf->simpleTables) {
  4941. $this->mpdf->cell[$k][$l]['border'] = 0;
  4942. $this->mpdf->cell[$k][$l]['border_details']['R'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
  4943. $this->mpdf->cell[$k][$l]['border_details']['L'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
  4944. $this->mpdf->cell[$k][$l]['border_details']['T'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
  4945. $this->mpdf->cell[$k][$l]['border_details']['B'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
  4946. $this->mpdf->cell[$k][$l]['border_details']['mbw'] = array('BL' => 0, 'BR' => 0, 'RT' => 0, 'RB' => 0, 'TL' => 0, 'TR' => 0, 'LT' => 0, 'LB' => 0);
  4947. if ($this->mpdf->packTableData) {
  4948. $this->mpdf->cell[$k][$l]['borderbin'] = $this->mpdf->_packCellBorder($this->mpdf->cell[$k][$l]);
  4949. unset($this->mpdf->cell[$k][$l]['border']);
  4950. unset($this->mpdf->cell[$k][$l]['border_details']);
  4951. }
  4952. }
  4953. }
  4954. }
  4955. }
  4956. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = $this->mpdf->cell;
  4957. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['wc'] = array_pad(array(), $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'], array('miw' => 0, 'maw' => 0));
  4958. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['hr'] = array_pad(array(), $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr'], 0);
  4959. // Move table footer <tfoot> row to end of table
  4960. if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) && count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'])) {
  4961. $tfrows = array();
  4962. foreach ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] AS $r => $val) {
  4963. if ($val) {
  4964. $tfrows[] = $r;
  4965. }
  4966. }
  4967. $temp = array();
  4968. $temptf = array();
  4969. foreach ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] AS $k => $row) {
  4970. if (in_array($k, $tfrows)) {
  4971. $temptf[] = $row;
  4972. } else {
  4973. $temp[] = $row;
  4974. }
  4975. }
  4976. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] = array();
  4977. for ($i = count($temp); $i < (count($temp) + count($temptf)); $i++) {
  4978. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$i] = true;
  4979. }
  4980. // Update nestedpos row references
  4981. if (isset($this->mpdf->table[($this->mpdf->tableLevel + 1)]) && count($this->mpdf->table[($this->mpdf->tableLevel + 1)])) {
  4982. foreach ($this->mpdf->table[($this->mpdf->tableLevel + 1)] AS $nid => $nested) {
  4983. $this->mpdf->table[($this->mpdf->tableLevel + 1)][$nid]['nestedpos'][0] -= count($temptf);
  4984. }
  4985. }
  4986. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = array_merge($temp, $temptf);
  4987. // Update other arays set on row number
  4988. // [trbackground-images] [trgradients]
  4989. $temptrbgi = array();
  4990. $temptrbgg = array();
  4991. $temptrbgc = array();
  4992. if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][-1])) {
  4993. $temptrbgc[-1] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][-1];
  4994. }
  4995. for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
  4996. if (!in_array($k, $tfrows)) {
  4997. $temptrbgi[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k] : null);
  4998. $temptrbgg[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k] : null);
  4999. $temptrbgc[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k] : null);
  5000. }
  5001. }
  5002. for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
  5003. if (in_array($k, $tfrows)) {
  5004. $temptrbgi[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k] : null);
  5005. $temptrbgg[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k] : null);
  5006. $temptrbgc[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k] : null);
  5007. }
  5008. }
  5009. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'] = $temptrbgi;
  5010. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'] = $temptrbgg;
  5011. $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'] = $temptrbgc;
  5012. // Should Update all other arays set on row number, but cell properties have been set so not needed
  5013. // [bgcolor] [trborder-left] [trborder-right] [trborder-top] [trborder-bottom]
  5014. }
  5015. if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['direction'] == 'rtl') {
  5016. $this->mpdf->_reverseTableDir($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]);
  5017. }
  5018. // Fix Borders *********************************************
  5019. $this->mpdf->_fixTableBorders($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]);
  5020. if ($this->mpdf->progressBar) {
  5021. $this->mpdf->UpdateProgressBar(7, 10, ' ');
  5022. } // *PROGRESS-BAR*
  5023. if ($this->mpdf->ColActive) {
  5024. $this->mpdf->table_rotate = 0;
  5025. } // *COLUMNS*
  5026. if ($this->mpdf->table_rotate <> 0) {
  5027. $this->mpdf->tablebuffer = '';
  5028. // Max width for rotated table
  5029. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 1);
  5030. $this->mpdf->tbrot_maxh = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']; // Max width for rotated table
  5031. $this->mpdf->tbrot_align = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['a'];
  5032. }
  5033. $this->mpdf->shrin_k = 1;
  5034. if ($this->mpdf->shrink_tables_to_fit < 1) {
  5035. $this->mpdf->shrink_tables_to_fit = 1;
  5036. }
  5037. if (!$this->mpdf->shrink_this_table_to_fit) {
  5038. $this->mpdf->shrink_this_table_to_fit = $this->mpdf->shrink_tables_to_fit;
  5039. }
  5040. if ($this->mpdf->tableLevel > 1) {
  5041. // deal with nested table
  5042. $this->mpdf->_tableColumnWidth($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]], true);
  5043. $tmiw = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['miw'];
  5044. $tmaw = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['maw'];
  5045. $tl = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['tl'];
  5046. // Go down to lower table level
  5047. $this->mpdf->tableLevel--;
  5048. // Reset lower level table
  5049. $this->mpdf->base_table_properties = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['baseProperties'];
  5050. // mPDF 5.7.3
  5051. $this->mpdf->default_font = $this->mpdf->base_table_properties['FONT-FAMILY'];
  5052. $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
  5053. $this->mpdf->default_font_size = $this->mpdf->ConvertSize($this->mpdf->base_table_properties['FONT-SIZE']) * (_MPDFK);
  5054. $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
  5055. $this->mpdf->cell = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'];
  5056. if (isset($this->mpdf->cell['PARENTCELL'])) {
  5057. if ($this->mpdf->cell['PARENTCELL']) {
  5058. $this->mpdf->restoreInlineProperties($this->mpdf->cell['PARENTCELL']);
  5059. }
  5060. unset($this->mpdf->cell['PARENTCELL']);
  5061. }
  5062. $this->mpdf->row = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currrow'];
  5063. $this->mpdf->col = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currcol'];
  5064. $objattr = array();
  5065. $objattr['type'] = 'nestedtable';
  5066. $objattr['nestedcontent'] = $this->mpdf->tbctr[($this->mpdf->tableLevel + 1)];
  5067. $objattr['table'] = $this->mpdf->tbctr[$this->mpdf->tableLevel];
  5068. $objattr['row'] = $this->mpdf->row;
  5069. $objattr['col'] = $this->mpdf->col;
  5070. $objattr['level'] = $this->mpdf->tableLevel;
  5071. $e = "\xbb\xa4\xactype=nestedtable,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
  5072. $this->mpdf->_saveCellTextBuffer($e);
  5073. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $tl;
  5074. if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
  5075. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  5076. } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
  5077. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
  5078. }
  5079. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
  5080. if ((isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'] < $tmaw) || !isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'])) {
  5081. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'] = $tmaw;
  5082. }
  5083. if ((isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'] < $tmiw) || !isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'])) {
  5084. $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'] = $tmiw;
  5085. }
  5086. $this->mpdf->tdbegin = true;
  5087. $this->mpdf->nestedtablejustfinished = true;
  5088. $this->mpdf->ignorefollowingspaces = true;
  5089. return;
  5090. }
  5091. $this->mpdf->cMarginL = 0;
  5092. $this->mpdf->cMarginR = 0;
  5093. $this->mpdf->cMarginT = 0;
  5094. $this->mpdf->cMarginB = 0;
  5095. $this->mpdf->cellPaddingL = 0;
  5096. $this->mpdf->cellPaddingR = 0;
  5097. $this->mpdf->cellPaddingT = 0;
  5098. $this->mpdf->cellPaddingB = 0;
  5099. if (isset($this->mpdf->table[1][1]['overflow']) && $this->mpdf->table[1][1]['overflow'] == 'visible') {
  5100. if ($this->mpdf->kwt || $this->mpdf->table_rotate || $this->mpdf->table_keep_together || $this->mpdf->ColActive) {
  5101. $this->mpdf->kwt = false;
  5102. $this->mpdf->table_rotate = 0;
  5103. $this->mpdf->table_keep_together = false;
  5104. //throw new MpdfException("mPDF Warning: You cannot use CSS overflow:visible together with any of these functions: 'Keep-with-table', rotated tables, page-break-inside:avoid, or columns");
  5105. }
  5106. $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], true);
  5107. $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
  5108. } else {
  5109. if (!$this->mpdf->kwt_saved) {
  5110. $this->mpdf->kwt_height = 0;
  5111. }
  5112. list($check, $tablemiw) = $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], true);
  5113. $save_table = $this->mpdf->table;
  5114. $reset_to_minimum_width = false;
  5115. $added_page = false;
  5116. if ($check > 1) {
  5117. if ($check > $this->mpdf->shrink_this_table_to_fit && $this->mpdf->table_rotate) {
  5118. if ($this->mpdf->y != $this->mpdf->tMargin) {
  5119. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5120. $this->mpdf->kwt_moved = true;
  5121. }
  5122. $added_page = true;
  5123. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5124. //$check = $tablemiw/$this->mpdf->tbrot_maxw; // undo any shrink
  5125. $check = 1; // undo any shrink
  5126. }
  5127. $reset_to_minimum_width = true;
  5128. }
  5129. if ($reset_to_minimum_width) {
  5130. $this->mpdf->shrin_k = $check;
  5131. $this->mpdf->default_font_size /= $this->mpdf->shrin_k;
  5132. $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
  5133. $this->mpdf->shrinkTable($this->mpdf->table[1][1], $this->mpdf->shrin_k);
  5134. $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], false); // repeat
  5135. // Starting at $this->mpdf->innermostTableLevel
  5136. // Shrink table values - and redo columnWidth
  5137. for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
  5138. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5139. $this->mpdf->shrinkTable($this->mpdf->table[$lvl][$nid], $this->mpdf->shrin_k);
  5140. $this->mpdf->_tableColumnWidth($this->mpdf->table[$lvl][$nid], false);
  5141. }
  5142. }
  5143. }
  5144. // Set table cell widths for top level table
  5145. // Use $shrin_k to resize but don't change again
  5146. $this->mpdf->SetLineHeight('', $this->mpdf->table[1][1]['cellLineHeight']);
  5147. // Top level table
  5148. $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
  5149. }
  5150. // Now work through any nested tables setting child table[w'] = parent cell['w']
  5151. // Now do nested tables _tableWidth
  5152. for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
  5153. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5154. // HERE set child table width = cell width
  5155. list($parentrow, $parentcol, $parentnid) = $this->mpdf->table[$lvl][$nid]['nestedpos'];
  5156. $c = & $this->mpdf->table[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
  5157. if (isset($c['colspan']) && $c['colspan'] > 1) {
  5158. $parentwidth = 0;
  5159. for ($cs = 0; $cs < $c['colspan']; $cs++) {
  5160. $parentwidth += $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol + $cs];
  5161. }
  5162. } else {
  5163. $parentwidth = $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol];
  5164. }
  5165. //$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
  5166. if (!$this->mpdf->simpleTables) {
  5167. if ($this->mpdf->packTableData) {
  5168. list($bt, $br, $bb, $bl) = $this->mpdf->_getBorderWidths($c['borderbin']);
  5169. } else {
  5170. $br = $c['border_details']['R']['w'];
  5171. $bl = $c['border_details']['L']['w'];
  5172. }
  5173. if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
  5174. $parentwidth -= $br + $bl + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
  5175. } else {
  5176. $parentwidth -= $br / 2 + $bl / 2 + $c['padding']['L'] + $c['padding']['R'];
  5177. }
  5178. } else if ($this->mpdf->simpleTables) {
  5179. if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
  5180. $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
  5181. } else {
  5182. $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] / 2 + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] / 2 + $c['padding']['L'] + $c['padding']['R'];
  5183. }
  5184. }
  5185. if (isset($this->mpdf->table[$lvl][$nid]['wpercent']) && $this->mpdf->table[$lvl][$nid]['wpercent'] && $lvl > 1) {
  5186. $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
  5187. } else if ($parentwidth > $this->mpdf->table[$lvl][$nid]['maw']) {
  5188. $this->mpdf->table[$lvl][$nid]['w'] = $this->mpdf->table[$lvl][$nid]['maw'];
  5189. } else {
  5190. $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
  5191. }
  5192. unset($c);
  5193. $this->mpdf->_tableWidth($this->mpdf->table[$lvl][$nid]);
  5194. }
  5195. }
  5196. // Starting at $this->mpdf->innermostTableLevel
  5197. // Cascade back up nested tables: setting heights back up the tree
  5198. for ($lvl = $this->mpdf->innermostTableLevel; $lvl > 0; $lvl--) {
  5199. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5200. list($tableheight, $maxrowheight, $fullpage, $remainingpage, $maxfirstrowheight) = $this->mpdf->_tableHeight($this->mpdf->table[$lvl][$nid]);
  5201. }
  5202. }
  5203. if ($this->mpdf->progressBar) {
  5204. $this->mpdf->UpdateProgressBar(7, 20, ' ');
  5205. } // *PROGRESS-BAR*
  5206. if ($this->mpdf->table[1][1]['overflow'] == 'visible') {
  5207. if ($maxrowheight > $fullpage) {
  5208. throw new MpdfException("mPDF Warning: A Table row is greater than available height. You cannot use CSS overflow:visible");
  5209. }
  5210. if ($maxfirstrowheight > $remainingpage) {
  5211. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5212. }
  5213. $r = 0;
  5214. $c = 0;
  5215. $p = 0;
  5216. $y = 0;
  5217. $finished = false;
  5218. while (!$finished) {
  5219. list($finished, $r, $c, $p, $y, $y0) = $this->mpdf->_tableWrite($this->mpdf->table[1][1], true, $r, $c, $p, $y);
  5220. if (!$finished) {
  5221. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5222. // If printed something on first spread, set same y
  5223. if ($r == 0 && $y0 > -1) {
  5224. $this->mpdf->y = $y0;
  5225. }
  5226. }
  5227. }
  5228. } else {
  5229. $recalculate = 1;
  5230. $forcerecalc = false;
  5231. // RESIZING ALGORITHM
  5232. if ($maxrowheight > $fullpage) {
  5233. $recalculate = $this->mpdf->tbsqrt($maxrowheight / $fullpage, 1);
  5234. $forcerecalc = true;
  5235. } else if ($this->mpdf->table_rotate) { // NB $remainingpage == $fullpage == the width of the page
  5236. if ($tableheight > $remainingpage) {
  5237. // If can fit on remainder of page whilst respecting autsize value..
  5238. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
  5239. $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, 1);
  5240. } else if (!$added_page) {
  5241. if ($this->mpdf->y != $this->mpdf->tMargin) {
  5242. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5243. $this->mpdf->kwt_moved = true;
  5244. }
  5245. $added_page = true;
  5246. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5247. // 0.001 to force it to recalculate
  5248. $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
  5249. }
  5250. } else {
  5251. $recalculate = 1;
  5252. }
  5253. } else if ($this->mpdf->table_keep_together || ($this->mpdf->table[1][1]['nr'] == 1 && !$this->mpdf->writingHTMLfooter)) {
  5254. if ($tableheight > $fullpage) {
  5255. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $fullpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
  5256. $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, 1);
  5257. } else if ($this->mpdf->tableMinSizePriority) {
  5258. $this->mpdf->table_keep_together = false;
  5259. $recalculate = 1.001;
  5260. } else {
  5261. if ($this->mpdf->y != $this->mpdf->tMargin) {
  5262. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5263. $this->mpdf->kwt_moved = true;
  5264. }
  5265. $added_page = true;
  5266. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5267. $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, 1);
  5268. }
  5269. } else if ($tableheight > $remainingpage) {
  5270. // If can fit on remainder of page whilst respecting autsize value..
  5271. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
  5272. $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, 1);
  5273. } else {
  5274. if ($this->mpdf->y != $this->mpdf->tMargin) {
  5275. // mPDF 6
  5276. if ($this->mpdf->AcceptPageBreak()) {
  5277. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5278. } else if ($this->mpdf->ColActive && $tableheight > (($this->mpdf->h - $this->mpdf->bMargin) - $this->mpdf->y0)) {
  5279. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5280. }
  5281. $this->mpdf->kwt_moved = true;
  5282. }
  5283. $added_page = true;
  5284. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5285. $recalculate = 1.001;
  5286. }
  5287. } else {
  5288. $recalculate = 1;
  5289. }
  5290. } else {
  5291. $recalculate = 1;
  5292. }
  5293. if ($recalculate > $this->mpdf->shrink_this_table_to_fit && !$forcerecalc) {
  5294. $recalculate = $this->mpdf->shrink_this_table_to_fit;
  5295. }
  5296. $iteration = 1;
  5297. // RECALCULATE
  5298. while ($recalculate <> 1) {
  5299. $this->mpdf->shrin_k1 = $recalculate;
  5300. $this->mpdf->shrin_k *= $recalculate;
  5301. $this->mpdf->default_font_size /= ($this->mpdf->shrin_k1);
  5302. $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
  5303. $this->mpdf->SetLineHeight('', $this->mpdf->table[1][1]['cellLineHeight']);
  5304. $this->mpdf->table = $save_table;
  5305. if ($this->mpdf->shrin_k <> 1) {
  5306. $this->mpdf->shrinkTable($this->mpdf->table[1][1], $this->mpdf->shrin_k);
  5307. }
  5308. $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], false); // repeat
  5309. // Starting at $this->mpdf->innermostTableLevel
  5310. // Shrink table values - and redo columnWidth
  5311. for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
  5312. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5313. if ($this->mpdf->shrin_k <> 1) {
  5314. $this->mpdf->shrinkTable($this->mpdf->table[$lvl][$nid], $this->mpdf->shrin_k);
  5315. }
  5316. $this->mpdf->_tableColumnWidth($this->mpdf->table[$lvl][$nid], false);
  5317. }
  5318. }
  5319. // Set table cell widths for top level table
  5320. // Top level table
  5321. $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
  5322. // Now work through any nested tables setting child table[w'] = parent cell['w']
  5323. // Now do nested tables _tableWidth
  5324. for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
  5325. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5326. // HERE set child table width = cell width
  5327. list($parentrow, $parentcol, $parentnid) = $this->mpdf->table[$lvl][$nid]['nestedpos'];
  5328. $c = & $this->mpdf->table[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
  5329. if (isset($c['colspan']) && $c['colspan'] > 1) {
  5330. $parentwidth = 0;
  5331. for ($cs = 0; $cs < $c['colspan']; $cs++) {
  5332. $parentwidth += $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol + $cs];
  5333. }
  5334. } else {
  5335. $parentwidth = $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol];
  5336. }
  5337. //$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
  5338. if (!$this->mpdf->simpleTables) {
  5339. if ($this->mpdf->packTableData) {
  5340. list($bt, $br, $bb, $bl) = $this->mpdf->_getBorderWidths($c['borderbin']);
  5341. } else {
  5342. $br = $c['border_details']['R']['w'];
  5343. $bl = $c['border_details']['L']['w'];
  5344. }
  5345. if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
  5346. $parentwidth -= $br + $bl + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
  5347. } else {
  5348. $parentwidth -= $br / 2 + $bl / 2 + $c['padding']['L'] + $c['padding']['R'];
  5349. }
  5350. } else if ($this->mpdf->simpleTables) {
  5351. if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
  5352. $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
  5353. } else {
  5354. $parentwidth -= ($this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w']) / 2 + $c['padding']['L'] + $c['padding']['R'];
  5355. }
  5356. }
  5357. if (isset($this->mpdf->table[$lvl][$nid]['wpercent']) && $this->mpdf->table[$lvl][$nid]['wpercent'] && $lvl > 1) {
  5358. $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
  5359. } else if ($parentwidth > $this->mpdf->table[$lvl][$nid]['maw']) {
  5360. $this->mpdf->table[$lvl][$nid]['w'] = $this->mpdf->table[$lvl][$nid]['maw'];
  5361. } else {
  5362. $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
  5363. }
  5364. unset($c);
  5365. $this->mpdf->_tableWidth($this->mpdf->table[$lvl][$nid]);
  5366. }
  5367. }
  5368. // Starting at $this->mpdf->innermostTableLevel
  5369. // Cascade back up nested tables: setting heights back up the tree
  5370. for ($lvl = $this->mpdf->innermostTableLevel; $lvl > 0; $lvl--) {
  5371. for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
  5372. list($tableheight, $maxrowheight, $fullpage, $remainingpage, $maxfirstrowheight) = $this->mpdf->_tableHeight($this->mpdf->table[$lvl][$nid]);
  5373. }
  5374. }
  5375. // RESIZING ALGORITHM
  5376. if ($maxrowheight > $fullpage) {
  5377. $recalculate = $this->mpdf->tbsqrt($maxrowheight / $fullpage, $iteration);
  5378. $iteration++;
  5379. } else if ($this->mpdf->table_rotate && $tableheight > $remainingpage && !$added_page) {
  5380. // If can fit on remainder of page whilst respecting autosize value..
  5381. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
  5382. $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration);
  5383. $iteration++;
  5384. } else {
  5385. if (!$added_page) {
  5386. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5387. $added_page = true;
  5388. $this->mpdf->kwt_moved = true;
  5389. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5390. }
  5391. // 0.001 to force it to recalculate
  5392. $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
  5393. }
  5394. } else if ($this->mpdf->table_keep_together || ($this->mpdf->table[1][1]['nr'] == 1 && !$this->mpdf->writingHTMLfooter)) {
  5395. if ($tableheight > $fullpage) {
  5396. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
  5397. $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration);
  5398. $iteration++;
  5399. } else if ($this->mpdf->tableMinSizePriority) {
  5400. $this->mpdf->table_keep_together = false;
  5401. $recalculate = (1 / $this->mpdf->shrin_k) + 0.001;
  5402. } else {
  5403. if (!$added_page && $this->mpdf->y != $this->mpdf->tMargin) {
  5404. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5405. $added_page = true;
  5406. $this->mpdf->kwt_moved = true;
  5407. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5408. }
  5409. $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration);
  5410. $iteration++;
  5411. }
  5412. } else if ($tableheight > $remainingpage) {
  5413. // If can fit on remainder of page whilst respecting autosize value..
  5414. if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
  5415. $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration);
  5416. $iteration++;
  5417. } else {
  5418. if (!$added_page) {
  5419. // mPDF 6
  5420. if ($this->mpdf->AcceptPageBreak()) {
  5421. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5422. } else if ($this->mpdf->ColActive && $tableheight > (($this->mpdf->h - $this->mpdf->bMargin) - $this->mpdf->y0)) {
  5423. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5424. }
  5425. $added_page = true;
  5426. $this->mpdf->kwt_moved = true;
  5427. $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
  5428. }
  5429. //$recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
  5430. $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
  5431. }
  5432. } else {
  5433. $recalculate = 1;
  5434. }
  5435. } else {
  5436. $recalculate = 1;
  5437. }
  5438. }
  5439. if ($maxfirstrowheight > $remainingpage && !$added_page && !$this->mpdf->table_rotate && !$this->mpdf->ColActive && !$this->mpdf->table_keep_together && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) {
  5440. $this->mpdf->AddPage($this->mpdf->CurOrientation);
  5441. $this->mpdf->kwt_moved = true;
  5442. }
  5443. // keep-with-table: if page has advanced, print out buffer now, else done in fn. _Tablewrite()
  5444. if ($this->mpdf->kwt_saved && $this->mpdf->kwt_moved) {
  5445. $this->mpdf->printkwtbuffer();
  5446. $this->mpdf->kwt_moved = false;
  5447. $this->mpdf->kwt_saved = false;
  5448. }
  5449. if ($this->mpdf->progressBar) {
  5450. $this->mpdf->UpdateProgressBar(7, 30, ' ');
  5451. } // *PROGRESS-BAR*
  5452. // Recursively writes all tables starting at top level
  5453. $this->mpdf->_tableWrite($this->mpdf->table[1][1]);
  5454. if ($this->mpdf->table_rotate && $this->mpdf->tablebuffer) {
  5455. $this->mpdf->PageBreakTrigger = $this->mpdf->h - $this->mpdf->bMargin;
  5456. $save_tr = $this->mpdf->table_rotate;
  5457. $save_y = $this->mpdf->y;
  5458. $this->mpdf->table_rotate = 0;
  5459. $this->mpdf->y = $this->mpdf->tbrot_y0;
  5460. $h = $this->mpdf->tbrot_w;
  5461. $this->mpdf->DivLn($h, $this->mpdf->blklvl, true);
  5462. $this->mpdf->table_rotate = $save_tr;
  5463. $this->mpdf->y = $save_y;
  5464. $this->mpdf->printtablebuffer();
  5465. }
  5466. $this->mpdf->table_rotate = 0;
  5467. }
  5468. $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
  5469. $this->mpdf->maxPosR = max($this->mpdf->maxPosR, ($this->mpdf->x + $this->mpdf->table[1][1]['w']));
  5470. $this->mpdf->blockjustfinished = true;
  5471. $this->mpdf->lastblockbottommargin = $this->mpdf->table[1][1]['margin']['B'];
  5472. //Reset values
  5473. if (isset($this->mpdf->table[1][1]['page_break_after'])) {
  5474. $page_break_after = $this->mpdf->table[1][1]['page_break_after'];
  5475. } else {
  5476. $page_break_after = '';
  5477. }
  5478. // Keep-with-table
  5479. $this->mpdf->kwt = false;
  5480. $this->mpdf->kwt_y0 = 0;
  5481. $this->mpdf->kwt_x0 = 0;
  5482. $this->mpdf->kwt_height = 0;
  5483. $this->mpdf->kwt_buffer = array();
  5484. $this->mpdf->kwt_Links = array();
  5485. $this->mpdf->kwt_Annots = array();
  5486. $this->mpdf->kwt_moved = false;
  5487. $this->mpdf->kwt_saved = false;
  5488. $this->mpdf->kwt_Reference = array();
  5489. $this->mpdf->kwt_BMoutlines = array();
  5490. $this->mpdf->kwt_toc = array();
  5491. $this->mpdf->shrin_k = 1;
  5492. $this->mpdf->shrink_this_table_to_fit = 0;
  5493. unset($this->mpdf->table);
  5494. $this->mpdf->table = array(); //array
  5495. $this->mpdf->tableLevel = 0;
  5496. $this->mpdf->tbctr = array();
  5497. $this->mpdf->innermostTableLevel = 0;
  5498. $this->mpdf->cssmgr->tbCSSlvl = 0;
  5499. $this->mpdf->cssmgr->tablecascadeCSS = array();
  5500. unset($this->mpdf->cell);
  5501. $this->mpdf->cell = array(); //array
  5502. $this->mpdf->col = -1; //int
  5503. $this->mpdf->row = -1; //int
  5504. $this->mpdf->Reset();
  5505. $this->mpdf->cellPaddingL = 0;
  5506. $this->mpdf->cellPaddingT = 0;
  5507. $this->mpdf->cellPaddingR = 0;
  5508. $this->mpdf->cellPaddingB = 0;
  5509. $this->mpdf->cMarginL = 0;
  5510. $this->mpdf->cMarginT = 0;
  5511. $this->mpdf->cMarginR = 0;
  5512. $this->mpdf->cMarginB = 0;
  5513. $this->mpdf->default_font_size = $this->mpdf->original_default_font_size;
  5514. $this->mpdf->default_font = $this->mpdf->original_default_font;
  5515. $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
  5516. $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
  5517. $this->mpdf->SetLineHeight();
  5518. if (isset($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties'])) {
  5519. $this->mpdf->restoreInlineProperties($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']);
  5520. }
  5521. if ($this->mpdf->progressBar) {
  5522. $this->mpdf->UpdateProgressBar(7, 100, ' ');
  5523. } // *PROGRESS-BAR*
  5524. if ($page_break_after) {
  5525. $save_blklvl = $this->mpdf->blklvl;
  5526. $save_blk = $this->mpdf->blk;
  5527. $save_silp = $this->mpdf->saveInlineProperties();
  5528. $save_ilp = $this->mpdf->InlineProperties;
  5529. $save_bflp = $this->mpdf->InlineBDF;
  5530. $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
  5531. // mPDF 6 pagebreaktype
  5532. $startpage = $this->mpdf->page;
  5533. $pagebreaktype = $this->mpdf->defaultPagebreakType;
  5534. if ($this->mpdf->ColActive) {
  5535. $pagebreaktype = 'cloneall';
  5536. }
  5537. // mPDF 6 pagebreaktype
  5538. $this->mpdf->_preForcedPagebreak($pagebreaktype);
  5539. if ($page_break_after == 'RIGHT') {
  5540. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  5541. } else if ($page_break_after == 'LEFT') {
  5542. $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  5543. } else {
  5544. $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
  5545. }
  5546. // mPDF 6 pagebreaktype
  5547. $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
  5548. $this->mpdf->InlineProperties = $save_ilp;
  5549. $this->mpdf->InlineBDF = $save_bflp;
  5550. $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
  5551. $this->mpdf->restoreInlineProperties($save_silp);
  5552. }
  5553. }
  5554. /* -- END TABLES -- */
  5555. }
  5556. }