📄 class.pdf.php
字号:
$o['info']['mediaBox'] = $options; // which should be an array of 4 numbers break; case 'font': $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']); break; case 'extGState': $o['info']['extGStates'][] = array('objNum' => $options['objNum'], 'stateNum' => $options['stateNum']); break; case 'xObject': $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']); break; case 'out': if (count($o['info']['pages'])) { $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids ["; foreach($o['info']['pages'] as $k=>$v) { $res.= $v." 0 R\n"; } $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']); if ( (isset($o['info']['fonts']) && count($o['info']['fonts'])) || isset($o['info']['procset']) || (isset($o['info']['extGStates']) && count($o['info']['extGStates']))) { $res.= "\n/Resources <<"; if (isset($o['info']['procset'])) { $res.= "\n/ProcSet ".$o['info']['procset']." 0 R"; } if (isset($o['info']['fonts']) && count($o['info']['fonts'])) { $res.= "\n/Font << "; foreach($o['info']['fonts'] as $finfo) { $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R"; } $res.= " >>"; } if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) { $res.= "\n/XObject << "; foreach($o['info']['xObjects'] as $finfo) { $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R"; } $res.= " >>"; } if ( isset($o['info']['extGStates']) && count($o['info']['extGStates'])) { $res.= "\n/ExtGState << "; foreach ($o['info']['extGStates'] as $gstate) { $res.= "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R"; } $res.= " >>"; } $res.= "\n>>"; if (isset($o['info']['mediaBox'])) { $tmp = $o['info']['mediaBox']; $res.= "\n/MediaBox [".sprintf('%.3f', $tmp[0]) .' '.sprintf('%.3f', $tmp[1]) .' '.sprintf('%.3f', $tmp[2]) .' '.sprintf('%.3f', $tmp[3]) .']'; } } $res.= "\n >>\nendobj"; } else { $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"; } return $res; break; } } /** * define the outlines in the doc, empty for now */ function o_outlines($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array())); $this->o_catalog($this->catalogId, 'outlines', $id); break; case 'outline': $o['info']['outlines'][] = $options; break; case 'out': if (count($o['info']['outlines'])) { $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids ["; foreach($o['info']['outlines'] as $k=>$v) { $res.= $v." 0 R "; } $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj"; } else { $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj"; } return $res; break; } } /** * an object to hold the font description */ function o_font($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': $this->objects[$id] = array('t' => 'font', 'info' => array('name' => $options['name'], 'SubType' => 'Type1')); $fontNum = $this->numFonts; $this->objects[$id]['info']['fontNum'] = $fontNum; // deal with the encoding and the differences if (isset($options['differences'])) { // then we'll need an encoding dictionary $this->numObj++; $this->o_fontEncoding($this->numObj, 'new', $options); $this->objects[$id]['info']['encodingDictionary'] = $this->numObj; } else if (isset($options['encoding'])) { // we can specify encoding here switch ($options['encoding']) { case 'WinAnsiEncoding': case 'MacRomanEncoding': case 'MacExpertEncoding': $this->objects[$id]['info']['encoding'] = $options['encoding']; break; case 'none': break; default: $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; break; } } else { $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; } // also tell the pages node about the new font $this->o_pages($this->currentNode, 'font', array('fontNum' => $fontNum, 'objNum' => $id)); break; case 'add': foreach ($options as $k => $v) { switch ($k) { case 'BaseFont': $o['info']['name'] = $v; break; case 'FirstChar': case 'LastChar': case 'Widths': case 'FontDescriptor': case 'SubType': $this->addMessage('o_font '.$k." : ".$v); $o['info'][$k] = $v; break; } } break; case 'out': $res = "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n"; $res.= "/Name /F".$o['info']['fontNum']."\n"; $res.= "/BaseFont /".$o['info']['name']."\n"; if (isset($o['info']['encodingDictionary'])) { // then place a reference to the dictionary $res.= "/Encoding ".$o['info']['encodingDictionary']." 0 R\n"; } else if (isset($o['info']['encoding'])) { // use the specified encoding $res.= "/Encoding /".$o['info']['encoding']."\n"; } if (isset($o['info']['FirstChar'])) { $res.= "/FirstChar ".$o['info']['FirstChar']."\n"; } if (isset($o['info']['LastChar'])) { $res.= "/LastChar ".$o['info']['LastChar']."\n"; } if (isset($o['info']['Widths'])) { $res.= "/Widths ".$o['info']['Widths']." 0 R\n"; } if (isset($o['info']['FontDescriptor'])) { $res.= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n"; } $res.= ">>\nendobj"; return $res; break; } } /** * a font descriptor, needed for including additional fonts */ function o_fontDescriptor($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options); break; case 'out': $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n"; foreach ($o['info'] as $label => $value) { switch ($label) { case 'Ascent': case 'CapHeight': case 'Descent': case 'Flags': case 'ItalicAngle': case 'StemV': case 'AvgWidth': case 'Leading': case 'MaxWidth': case 'MissingWidth': case 'StemH': case 'XHeight': case 'CharSet': if (strlen($value)) { $res.= '/'.$label.' '.$value."\n"; } break; case 'FontFile': case 'FontFile2': case 'FontFile3': $res.= '/'.$label.' '.$value." 0 R\n"; break; case 'FontBBox': $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n"; break; case 'FontName': $res.= '/'.$label.' /'.$value."\n"; break; } } $res.= ">>\nendobj"; return $res; break; } } /** * the font encoding */ function o_fontEncoding($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': // the options array should contain 'differences' and maybe 'encoding' $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options); break; case 'out': $res = "\n".$id." 0 obj\n<< /Type /Encoding\n"; if (!isset($o['info']['encoding'])) { $o['info']['encoding'] = 'WinAnsiEncoding'; } if ($o['info']['encoding'] != 'none') { $res.= "/BaseEncoding /".$o['info']['encoding']."\n"; } $res.= "/Differences \n["; $onum = -100; foreach($o['info']['differences'] as $num=>$label) { if ($num != $onum+1) { // we cannot make use of consecutive numbering $res.= "\n".$num." /".$label; } else { $res.= " /".$label; } $onum = $num; } $res.= "\n]\n>>\nendobj"; return $res; break; } } /** * the document procset, solves some problems with printing to old PS printers */ function o_procset($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1)); $this->o_pages($this->currentNode, 'procset', $id); $this->procsetObjectId = $id; break; case 'add': // this is to add new items to the procset list, despite the fact that this is considered // obselete, the items are required for printing to some postscript printers switch ($options) { case 'ImageB': case 'ImageC': case 'ImageI': $o['info'][$options] = 1; break; } break; case 'out': $res = "\n".$id." 0 obj\n["; foreach ($o['info'] as $label=>$val) { $res.= '/'.$label.' '; } $res.= "]\nendobj"; return $res; break; } } /** * define the document information */ function o_info($id, $action, $options = '') { if ($action != 'new') { $o = & $this->objects[$id]; } switch ($action) { case 'new': $this->infoObject = $id; $date = 'D:'.@date('Ymd'); $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date)); break; case 'Title': case 'Author': case 'Subject': case 'Keywords': case 'Creator': case 'Producer': case 'CreationDate': case 'ModDate': case 'Trapped': $o['info'][$action] = $options; break; case 'out': if ($this->encrypted) { $this->encryptInit($id); } $res = "\n".$id." 0 obj\n<<\n"; foreach ($o['info'] as $k=>$v) { $res.= '/'.$k.' ('; if ($this->encrypted) { $res.= $this->filterText($this->ARC4($v)); } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -