Ignore:
Timestamp:
11/17/09 09:02:41 (15 years ago)
Author:
amuller
Message:

Ticket #597 - melhoria no modulo gerenciador de arquivos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/filemanager/tp/dompdf/include/pdflib_adapter.cls.php

    r1575 r1654  
    3434 * @copyright 2004 Benj Carson 
    3535 * @author Benj Carson <benjcarson@digitaljunkies.ca> 
     36 * @contributor Helmut Tischer <htischer@weihenstephan.org> 
    3637 * @package dompdf 
    3738 * @version 0.5.1 
     39 * 
     40 * Changes 
     41 * @contributor Helmut Tischer <htischer@weihenstephan.org> 
     42 * @version 0.5.1.htischer.20090507 
     43 * - Clarify temp file name, optional debug output for temp file tracking 
    3844 */ 
    3945 
    40 /* $Id: pdflib_adapter.cls.php,v 1.23 2006/07/07 21:31:04 benjcarson Exp $ */ 
     46/* $Id: pdflib_adapter.cls.php 186 2009-10-19 22:42:06Z eclecticgeek@gmail.com $ */ 
    4147 
    4248/** 
     
    184190      $size = $paper; 
    185191    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) 
    186       $size = self::$PAPER_SIZES[$paper]; 
     192      $size = self::$PAPER_SIZES[mb_strtolower($paper)]; 
    187193    else 
    188194      $size = self::$PAPER_SIZES["letter"]; 
     
    219225      $this->_pdf->begin_document("",""); 
    220226    else { 
    221       $this->_file = tempnam(DOMPDF_TEMP_DIR, "dompdf_tmp_"); 
     227      $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; 
    222228      $this->_pdf->begin_document($this->_file,""); 
    223229    } 
     
    239245 
    240246        // Prefer ttfs to afms 
    241         if ( file_exists($file.".ttf") ) 
    242           $file .= ".ttf"; 
    243  
    244         else if ( file_exists($file .".TTF") ) 
    245           $file .= ".TTF"; 
    246  
    247         else if ( file_exists($file . ".pfb") ) 
    248           $file .= ".pfb"; 
    249  
    250         else if ( file_exists($file . ".PFB") ) 
    251           $file .= ".PFB"; 
    252  
    253         else 
     247        if ( file_exists($file.".ttf") ) { 
     248          $outline = "$file.ttf"; 
     249          $afm = null; 
     250 
     251        } else if ( file_exists($file .".TTF") ) { 
     252          $outline = "$file.TTF"; 
     253          $afm = null; 
     254 
     255        } else if ( file_exists($file . ".pfb") ) { 
     256          $outline = "$file.pfb"; 
     257 
     258          if ( file_exists($file . ".afm") ) 
     259            $afm = "$file.afm"; 
     260 
     261        } else if ( file_exists($file . ".PFB") ) { 
     262          $outline = "$file.PFB"; 
     263          if ( file_exists($file . ".AFM") ) 
     264            $afm = "$file.AFM"; 
     265        } else 
    254266          continue; 
    255267 
    256         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$file\}"); 
     268        $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); 
     269        if ( !is_null($afm) ) 
     270          $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); 
    257271      } 
    258272    } 
     
    283297  function get_pdflib() { return $this->_pdf; } 
    284298 
     299  /** 
     300   * Add meta information to the PDF 
     301   * 
     302   * @param string $label  label of the value (Creator, Producter, etc.) 
     303   * @param string $value  the text to set 
     304   */ 
     305  function add_info($label, $value) { 
     306    $this->_pdf->set_info($label, $value); 
     307  } 
     308   
    285309  /** 
    286310   * Opens a new 'object' (template in PDFLib-speak) 
     
    719743        return; // Local links are not allowed 
    720744      $url = build_url($proto, $host, $path, $file); 
    721       $url = str_replace("=", "%3D", rawurldecode($url)); 
    722  
     745      $url = '{' . rawurldecode($url) . '}'; 
     746       
    723747      $action = $this->_pdf->create_action("URI", "url=" . $url); 
    724748      $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); 
     
    754778  //........................................................................ 
    755779 
     780  /** 
     781   * Writes text at the specified x and y coordinates on every page 
     782   * 
     783   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced 
     784   * with their current values. 
     785   * 
     786   * See {@link Style::munge_colour()} for the format of the colour array. 
     787   * 
     788   * @param float $x 
     789   * @param float $y 
     790   * @param string $text the text to write 
     791   * @param string $font the font file to use 
     792   * @param float $size the font size, in points 
     793   * @param array $color 
     794   * @param float $adjust word spacing adjustment 
     795   * @param float $angle angle to write the text at, measured CW starting from the x-axis 
     796   */ 
    756797  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), 
    757798                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) { 
    758     $this->_page_text[] = compact("x", "y", "text", "font", "size", "color", "adjust", "angle"); 
    759  
     799    $_t = "text"; 
     800    $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); 
     801  } 
     802 
     803  //........................................................................ 
     804 
     805  /** 
     806   * Processes a script on every page 
     807   *  
     808   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. 
     809   *  
     810   * This function can be used to add page numbers to all pages 
     811   * after the first one, for example. 
     812   * 
     813   * @param string $code the script code 
     814   * @param string $type the language type for script 
     815   */ 
     816  function page_script($code, $type = "text/php") { 
     817    $_t = "script"; 
     818    $this->_page_text[] = compact("_t", "code", "type"); 
    760819  } 
    761820 
     
    786845 
    787846    for ($p = 1; $p <= $this->_page_count; $p++) { 
    788  
    789847      $this->_pdf->resume_page("pagenumber=$p"); 
    790848 
     
    792850        extract($pt); 
    793851 
    794         $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), 
    795                             array($p, $this->_page_count), $text); 
    796  
    797         $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); 
    798  
     852        switch ($_t) { 
     853 
     854        case "text": 
     855          $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), 
     856                              array($p, $this->_page_count), $text); 
     857          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); 
     858          break; 
     859 
     860        case "script": 
     861          if (!$eval) { 
     862            $eval = new PHP_Evaluator($this);   
     863          } 
     864          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); 
     865          break; 
     866        } 
    799867      } 
    800868 
    801869      $this->_pdf->suspend_page(""); 
    802  
    803870    } 
    804871 
     
    851918        echo fread($fh,$chunk); 
    852919      fclose($fh); 
     920 
     921      //debugpng 
     922      if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; 
     923      if (!DEBUGKEEPTEMP) 
     924 
    853925      unlink($this->_file); 
    854926      $this->_file = null; 
     
    879951    else { 
    880952      $data = file_get_contents($this->_file); 
     953 
     954      //debugpng 
     955      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; 
     956      if (!DEBUGKEEPTEMP) 
     957 
    881958      unlink($this->_file); 
    882959      $this->_file = null; 
Note: See TracChangeset for help on using the changeset viewer.