=='.z'); if(!$compressed && isset($info['length2'])) { $header=(ord($font{0})==128); if($header) { //Strip first binary header $font=substr($font,6); } if($header && ord($font{$info['length1']})==128) { //Strip second binary header $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6); } } $this->_out('<_out('/Filter /FlateDecode'); } $this->_out('/Length1 '.$info['length1']); if(isset($info['length2'])) { $this->_out('/Length2 '.$info['length2'].' /Length3 0'); } $this->_out('>>'); $this->_putstream($font); $this->_out('endobj'); } set_magic_quotes_runtime($mqr); foreach($this->fonts as $k=>$font) { //Font objects $this->fonts[$k]['n']=$this->n+1; $type=$font['type']; $name=$font['name']; if($type=='core') { //Standard font $this->_newobj(); $this->_out('<_out('/BaseFont /'.$name); $this->_out('/Subtype /Type1'); if($name!='Symbol' && $name!='ZapfDingbats') { $this->_out('/Encoding /WinAnsiEncoding'); } $this->_out('>>'); $this->_out('endobj'); } elseif($type=='Type1' OR $type=='TrueType') { //Additional Type1 or TrueType font $this->_newobj(); $this->_out('<_out('/BaseFont /'.$name); $this->_out('/Subtype /'.$type); $this->_out('/FirstChar 32 /LastChar 255'); $this->_out('/Widths '.($this->n+1).' 0 R'); $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); if($font['enc']) { if(isset($font['diff'])) { $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); } else { $this->_out('/Encoding /WinAnsiEncoding'); } } $this->_out('>>'); $this->_out('endobj'); //Widths $this->_newobj(); $cw=&$font['cw']; $s='['; for($i=32;$i<=255;$i++) { $s.=$cw[chr($i)].' '; } $this->_out($s.']'); $this->_out('endobj'); //Descriptor $this->_newobj(); $s='<$v) { $s.=' /'.$k.' '.$v; } $file = $font['file']; if($file) { $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; } $this->_out($s.'>>'); $this->_out('endobj'); } else { //Allow for additional types $mtd='_put'.strtolower($type); if(!method_exists($this, $mtd)) { $this->Error('Unsupported font type: '.$type); } $this->$mtd($font); } } } /** * _putimages * @access protected */ function _putimages() { $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; reset($this->images); while(list($file,$info)=each($this->images)) { $this->_newobj(); $this->images[$file]['n']=$this->n; $this->_out('<_out('/Subtype /Image'); $this->_out('/Width '.$info['w']); $this->_out('/Height '.$info['h']); if (isset($info["masked"])) { $this->_out('/SMask '.($this->n-1).' 0 R'); } if($info['cs']=='Indexed') { $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); } else { $this->_out('/ColorSpace /'.$info['cs']); if($info['cs']=='DeviceCMYK') { $this->_out('/Decode [1 0 1 0 1 0 1 0]'); } } $this->_out('/BitsPerComponent '.$info['bpc']); if(isset($info['f'])) { $this->_out('/Filter /'.$info['f']); } if(isset($info['parms'])) { $this->_out($info['parms']); } if(isset($info['trns']) and is_array($info['trns'])) { $trns=''; for($i=0;$i_out('/Mask ['.$trns.']'); } $this->_out('/Length '.strlen($info['data']).'>>'); $this->_putstream($info['data']); unset($this->images[$file]['data']); $this->_out('endobj'); //Palette if($info['cs']=='Indexed') { $this->_newobj(); $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal']; $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); $this->_putstream($pal); $this->_out('endobj'); } } } /** * _putxobjectdict * @access protected */ function _putxobjectdict() { foreach($this->images as $image) { $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); } } /** * _putresourcedict * @access protected */ function _putresourcedict(){ $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); $this->_out('/Font <<'); foreach($this->fonts as $font) { $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); } $this->_out('>>'); $this->_out('/XObject <<'); $this->_putxobjectdict(); $this->_out('>>'); } /** * _putresources * @access protected */ function _putresources() { $this->_putfonts(); $this->_putimages(); //Resource dictionary $this->offsets[2]=strlen($this->buffer); $this->_out('2 0 obj'); $this->_out('<<'); $this->_putresourcedict(); $this->_out('>>'); $this->_out('endobj'); $this->_putjavascript(); $this->_putbookmarks(); // encryption if ($this->encrypted) { $this->_newobj(); $this->enc_obj_id = $this->n; $this->_out('<<'); $this->_putencryption(); $this->_out('>>'); $this->_out('endobj'); } } /** * _putinfo * Adds some meta information * @access protected */ function _putinfo() { $this->_out('/CreationDate ('.$this->_escape('D:'.date('YmdHis')).')'); $this->_out('/ModDate ('.$this->_escape('D:'.date('YmdHis')).')'); $this->_out('/Producer '.$this->_textstring(PDF_PRODUCER)); if(!empty($this->title)) { $this->_out('/Title '.$this->_textstring($this->title)); } if(!empty($this->subject)) { $this->_out('/Subject '.$this->_textstring($this->subject)); } if(!empty($this->author)) { $this->_out('/Author '.$this->_textstring($this->author)); } if(!empty($this->keywords)) { $this->_out('/Keywords '.$this->_textstring($this->keywords)); } if(!empty($this->creator)) { $this->_out('/Creator '.$this->_textstring($this->creator)); } } /** * _putcatalog * @access protected */ function _putcatalog() { $this->_out('/Type /Catalog'); $this->_out('/Pages 1 0 R'); if($this->ZoomMode=='fullpage') { $this->_out('/OpenAction [3 0 R /Fit]'); } elseif($this->ZoomMode=='fullwidth') { $this->_out('/OpenAction [3 0 R /FitH null]'); } elseif($this->ZoomMode=='real') { $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); } elseif(!is_string($this->ZoomMode)) { $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); } if($this->LayoutMode=='single') { $this->_out('/PageLayout /SinglePage'); } elseif($this->LayoutMode=='continuous') { $this->_out('/PageLayout /OneColumn'); } elseif($this->LayoutMode=='two') { $this->_out('/PageLayout /TwoColumnLeft'); } if (!empty($this->javascript)) { $this->_out('/Names <n_js).' 0 R>>'); } if(count($this->outlines)>0) { $this->_out('/Outlines '.$this->OutlineRoot.' 0 R'); $this->_out('/PageMode /UseOutlines'); } if($this->rtl) { $this->_out('/ViewerPreferences << /Direction /R2L >>'); } } /** * _puttrailer * @access protected */ function _puttrailer() { $this->_out('/Size '.($this->n+1)); $this->_out('/Root '.$this->n.' 0 R'); $this->_out('/Info '.($this->n-1).' 0 R'); if ($this->encrypted) { $this->_out('/Encrypt '.$this->enc_obj_id.' 0 R'); $this->_out('/ID [()()]'); } } /** * _putheader * @access protected */ function _putheader() { $this->_out('%PDF-'.$this->PDFVersion); } /** * _enddoc * @access protected */ function _enddoc() { $this->_putheader(); $this->_putpages(); $this->_putresources(); //Info $this->_newobj(); $this->_out('<<'); $this->_putinfo(); $this->_out('>>'); $this->_out('endobj'); //Catalog $this->_newobj(); $this->_out('<<'); $this->_putcatalog(); $this->_out('>>'); $this->_out('endobj'); //Cross-ref $o=strlen($this->buffer); $this->_out('xref'); $this->_out('0 '.($this->n+1)); $this->_out('0000000000 65535 f '); for($i=1;$i<=$this->n;$i++) { $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); } //Trailer $this->_out('trailer'); $this->_out('<<'); $this->_puttrailer(); $this->_out('>>'); $this->_out('startxref'); $this->_out($o); $this->_out('%%EOF'); $this->state=3; } /** * _beginpage * @access protected */ function _beginpage($orientation) { $this->page++; $this->pages[$this->page]=''; $this->state=2; if ($this->rtl) { $this->x = $this->w - $this->rMargin; } else { $this->x = $this->lMargin; } $this->y = $this->tMargin; $this->FontFamily=''; //Page orientation if(empty($orientation)) { $orientation=$this->DefOrientation; } else { $orientation=strtoupper($orientation{0}); if($orientation!=$this->DefOrientation) { $this->OrientationChanges[$this->page]=true; } } if($orientation!=$this->CurOrientation) { //Change orientation if($orientation=='P') { $this->wPt=$this->fwPt; $this->hPt=$this->fhPt; $this->w=$this->fw; $this->h=$this->fh; } else { $this->wPt=$this->fhPt; $this->hPt=$this->fwPt; $this->w=$this->fh; $this->h=$this->fw; } $this->PageBreakTrigger=$this->h-$this->bMargin; $this->CurOrientation=$orientation; } } /** * End of page contents * @access protected */ function _endpage() { $this->state=1; } /** * Begin a new object * @access protected */ function _newobj() { $this->n++; $this->offsets[