- Timestamp:
- 11/17/09 09:02:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/filemanager/tp/dompdf/include/pdflib_adapter.cls.php
r1575 r1654 34 34 * @copyright 2004 Benj Carson 35 35 * @author Benj Carson <benjcarson@digitaljunkies.ca> 36 * @contributor Helmut Tischer <htischer@weihenstephan.org> 36 37 * @package dompdf 37 38 * @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 38 44 */ 39 45 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 $ */ 41 47 42 48 /** … … 184 190 $size = $paper; 185 191 else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) 186 $size = self::$PAPER_SIZES[ $paper];192 $size = self::$PAPER_SIZES[mb_strtolower($paper)]; 187 193 else 188 194 $size = self::$PAPER_SIZES["letter"]; … … 219 225 $this->_pdf->begin_document("",""); 220 226 else { 221 $this->_file = tempnam(DOMPDF_TEMP_DIR, " dompdf_tmp_");227 $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; 222 228 $this->_pdf->begin_document($this->_file,""); 223 229 } … … 239 245 240 246 // 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 254 266 continue; 255 267 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\}"); 257 271 } 258 272 } … … 283 297 function get_pdflib() { return $this->_pdf; } 284 298 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 285 309 /** 286 310 * Opens a new 'object' (template in PDFLib-speak) … … 719 743 return; // Local links are not allowed 720 744 $url = build_url($proto, $host, $path, $file); 721 $url = str_replace("=", "%3D", rawurldecode($url));722 745 $url = '{' . rawurldecode($url) . '}'; 746 723 747 $action = $this->_pdf->create_action("URI", "url=" . $url); 724 748 $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); … … 754 778 //........................................................................ 755 779 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 */ 756 797 function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), 757 798 $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"); 760 819 } 761 820 … … 786 845 787 846 for ($p = 1; $p <= $this->_page_count; $p++) { 788 789 847 $this->_pdf->resume_page("pagenumber=$p"); 790 848 … … 792 850 extract($pt); 793 851 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 } 799 867 } 800 868 801 869 $this->_pdf->suspend_page(""); 802 803 870 } 804 871 … … 851 918 echo fread($fh,$chunk); 852 919 fclose($fh); 920 921 //debugpng 922 if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; 923 if (!DEBUGKEEPTEMP) 924 853 925 unlink($this->_file); 854 926 $this->_file = null; … … 879 951 else { 880 952 $data = file_get_contents($this->_file); 953 954 //debugpng 955 if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; 956 if (!DEBUGKEEPTEMP) 957 881 958 unlink($this->_file); 882 959 $this->_file = null;
Note: See TracChangeset
for help on using the changeset viewer.