Logo Search packages:      
Sourcecode: acidbase version File versions  Download package

Cpdf::o_page ( id,
action,
options = '' 
)

a page object, it also creates a contents object to hold its contents

Definition at line 821 of file class.pdf.php.

References $options, o_contents(), and o_pages().

Referenced by addObject(), newDocument(), newPage(), and o_annotation().

                                        {
  if ($action!='new'){
    $o =& $this->objects[$id];
  }
  switch ($action){
    case 'new':
      $this->numPages++;
      $this->objects[$id]=array('t'=>'page','info'=>array('parent'=>$this->currentNode,'pageNum'=>$this->numPages));
      if (is_array($options)){
        // then this must be a page insertion, array shoudl contain 'rid','pos'=[before|after]
        $options['id']=$id;
        $this->o_pages($this->currentNode,'page',$options);
      } else {
        $this->o_pages($this->currentNode,'page',$id);
      }
      $this->currentPage=$id;
      //make a contents object to go with this page
      $this->numObj++;
      $this->o_contents($this->numObj,'new',$id);
      $this->currentContents=$this->numObj;
      $this->objects[$id]['info']['contents']=array();
      $this->objects[$id]['info']['contents'][]=$this->numObj;
      $match = ($this->numPages%2 ? 'odd' : 'even');
      foreach($this->addLooseObjects as $oId=>$target){
        if ($target=='all' || $match==$target){
          $this->objects[$id]['info']['contents'][]=$oId;
        }
      }
      break;
    case 'content':
      $o['info']['contents'][]=$options;
      break;
    case 'annot':
      // add an annotation to this page
      if (!isset($o['info']['annot'])){
        $o['info']['annot']=array();
      }
      // $options should contain the id of the annotation dictionary
      $o['info']['annot'][]=$options;
      break;
    case 'out':
      $res="\n".$id." 0 obj\n<< /Type /Page";
      $res.="\n/Parent ".$o['info']['parent']." 0 R";
      if (isset($o['info']['annot'])){
        $res.="\n/Annots [";
        foreach($o['info']['annot'] as $aId){
          $res.=" ".$aId." 0 R";
        }
        $res.=" ]";
      }
      $count = count($o['info']['contents']);
      if ($count==1){
        $res.="\n/Contents ".$o['info']['contents'][0]." 0 R";
      } else if ($count>1){
        $res.="\n/Contents [\n";
        foreach ($o['info']['contents'] as $cId){
          $res.=$cId." 0 R\n";
        }
        $res.="]";
      }
      $res.="\n>>\nendobj";
      return $res;
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index