function saveState( $pageEnd = 0 )
    {
        if ( $pageEnd )
        {
            // this will be called at a new page to return the state to what it was on the
            // end of the previous page, before the stack was closed down
            // This is to get around not being able to have open 'q' across pages
            $opt = $this->stateStack[$pageEnd]; // ok to use this as stack starts numbering at 1
            $this->setColor($opt['col'],1);
            $this->setStrokeColor($opt['str'],1);
            $this->objects[$this->currentContents]['c'].="\n".$opt['lin'];
            //$this->currentLineStyle = $opt['lin'];
        }
        else
        {
            $this->nStateStack++;
            $this->stateStack[$this->nStateStack]=array( 'col' => $this->currentColour,
                                                         'str' => $this->currentStrokeColour,
                                                         'lin' => $this->currentLineStyle );
        }
        $this->objects[$this->currentContents]['c'] .= "\nq";
    }