/** * Writes a value * Needed to rebuild the source document * * @param mixed $value A PDF-Value. Structure of values see cases in this method */ function pdf_write_value(&$value) { if (is_subclass_of($this, 'TCPDF')) { parent::pdf_write_value($value); } switch ($value[0]) { case PDF_TYPE_TOKEN: $this->_straightOut($value[1] . ' '); break; case PDF_TYPE_NUMERIC: case PDF_TYPE_REAL: if (is_float($value[1]) && $value[1] != 0) { $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' '); } else { $this->_straightOut($value[1] . ' '); } break; case PDF_TYPE_ARRAY: // An array. Output the proper // structure and move on. $this->_straightOut('['); for ($i = 0; $i < count($value[1]); $i++) { $this->pdf_write_value($value[1][$i]); } $this->_out(']'); break; case PDF_TYPE_DICTIONARY: // A dictionary. $this->_straightOut('<<'); reset($value[1]); while (list($k, $v) = each($value[1])) { $this->_straightOut($k . ' '); $this->pdf_write_value($v); } $this->_straightOut('>>'); break; case PDF_TYPE_OBJREF: // An indirect object reference // Fill the object stack if needed $cpfn =& $this->current_parser->filename; if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { $this->_newobj(false, true); $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!! } $objid = $this->_don_obj_stack[$cpfn][$value[1]][0]; $this->_out($objid . ' 0 R'); break; case PDF_TYPE_STRING: // A string. $this->_straightOut('(' . $value[1] . ')'); break; case PDF_TYPE_STREAM: // A stream. First, output the // stream dictionary, then the // stream data itself. $this->pdf_write_value($value[1]); $this->_out('stream'); $this->_out($value[2][1]); $this->_out('endstream'); break; case PDF_TYPE_HEX: $this->_straightOut('<' . $value[1] . '>'); break; case PDF_TYPE_BOOLEAN: $this->_straightOut($value[1] ? 'true ' : 'false '); break; case PDF_TYPE_NULL: // The null object. $this->_straightOut('null '); break; } }
/** * Writes a value * Needed to rebuild the source document * * @param mixed $value A PDF-Value. Structure of values see cases in this method */ function pdf_write_value(&$value) { if (is_subclass_of($this, 'TCPDF')) { parent::pdf_write_value($value); } switch ($value[0]) { case PDF_TYPE_NUMERIC: case PDF_TYPE_TOKEN: case PDF_TYPE_REAL: // A numeric value or a token. // Simply output them $this->_out($value[1] . " ", false); break; case PDF_TYPE_ARRAY: // An array. Output the proper // structure and move on. $this->_out("[", false); for ($i = 0; $i < count($value[1]); $i++) { $this->pdf_write_value($value[1][$i]); } $this->_out("]"); break; case PDF_TYPE_DICTIONARY: // A dictionary. $this->_out("<<", false); reset($value[1]); while (list($k, $v) = each($value[1])) { $this->_out($k . " ", false); $this->pdf_write_value($v); } $this->_out(">>"); break; case PDF_TYPE_OBJREF: // An indirect object reference // Fill the object stack if needed $cpfn =& $this->current_parser->filename; if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { $this->_newobj(false, true); $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!! } $objid = $this->_don_obj_stack[$cpfn][$value[1]][0]; $this->_out("{$objid} 0 R"); break; case PDF_TYPE_STRING: // A string. $this->_out('(' . $value[1] . ')'); break; case PDF_TYPE_STREAM: // A stream. First, output the // stream dictionary, then the // stream data itself. $this->pdf_write_value($value[1]); $this->_out("stream"); $this->_out($value[2][1]); $this->_out("endstream"); break; case PDF_TYPE_HEX: $this->_out("<" . $value[1] . ">"); break; case PDF_TYPE_BOOLEAN: $this->_out($value[1] ? 'true ' : 'false ', false); break; case PDF_TYPE_NULL: // The null object. $this->_out("null"); break; } }