1

Bonjour,

Avant tout, merci pour cette excellente librairie. J'utilise la version 4.03. Je souhaite prolonger les lignes d'un tableau principal (courant sur toutes les pages) jusqu'au au dessus du bloc de fin de la dernière page.
J'ai ajouté une balise me permettant de placer un bloc de taille variable en fin de la dernière page. En positionnant ce bloc en fin de page, je souhaitais également pouvoir retoucher la taille du tableau principal pour le prolonger jusqu'au dessus de ce bloc de fin. Je me suis rendu code que la variable $this->_parsingHtml contient tout le code HTML découpé balise par balise. J'ai donc pensé pouvoir modifier la taille du tableau principal en retrouvant ce tableau dans $this->_parsingHtml et modifier le style height. Voici mon code :

    protected $_headerHeight      = 0;    // maximum height of header
    protected $_endLastPageHeight = 0;    // maximum height of footer at the end of the last page
    
    /**
     * tag : END_LAST_PAGE
     * mode : OPEN
     *
     * @param  array $param
     * @return boolean
     */
    protected function _tag_open_END_LAST_PAGE($param)
    {
        if ($this->_isForOneLine) return false;

        // we create a sub HTML2PFDF, and we execute on it the content of the footer, to get the height of it
        $sub = null;
        $this->_createSubHTML($sub);
        $sub->parsingHtml->code = $this->parsingHtml->getLevel($this->_parsePos);
        $sub->_makeHTMLcode();
        $this->_endLastPageHeight = $sub->_maxY;
        // destroy the sub HTML2PDF
        $this->_destroySubHTML($sub);

        // we create a sub HTML2PFDF, and we execute on it the content of the header, to get the height of it
        $sub = null;
        $this->_createSubHTML($sub);
        $sub->parsingHtml->code = $this->parsingHtml->getLevel(1); // page_header est la 1ere balise dans la balise page
        $sub->_makeHTMLcode();
        $this->_headerHeight = $sub->_maxY;
        // destroy the sub HTML2PDF
        $this->_destroySubHTML($sub);

        // if the content does not fit on the page => new page
        if (($this->pdf->getY() + $this->_endLastPageHeight + $this->pdf->getbMargin()) > $this->pdf->getH())
        {
            $this->_setNewPage();
        }

        // Set content at the bottom
        $this->pdf->setY($this->pdf->getH() - $this->pdf->getbMargin() - $this->_endLastPageHeight);
        
        // Prolongement des lignes du tableau principal
        $nb_pages = $this->pdf->getNumPages(); // Récupère le nombre de pages insérées
        if ($nb_pages == 1)
        {
            // S'il n'y a qu'une seule page, il faut prolonger la hauteur du tableau principal 
            // jusqu'au tableau présentant les totaux - une marge de 5mm
            $h = $this->pdf->getH() - $this->_headerHeight - $this->_endLastPageHeight - $this->pdf->getbMargin() - 5;
        }
        if ($nb_pages > 1)
        {
           $nb_pages_sans_le_bloc_de_fin = $nb_pages - 1;
           // Toutes les pages avant la dernière
           $h = $nb_pages_sans_le_bloc_de_fin * ($this->pdf->getH() - $this->_headerHeight - $this->pdf->getbMargin());
           // + la dernière page
           $h += $this->pdf->getH() - $this->_headerHeight - $this->_endLastPageHeight - $this->pdf->getbMargin() - 5;
        }
        $this->parsingHtml->code[44]['param']['style'] = array('height' => $h.'mm'); // L'indice 44 correspond au tableau dont je veux modifier la propriété height.
        
        return true;
    }

    /**
     * tag : END_LAST_PAGE
     * mode : CLOSE
     *
     * @param  array $param
     * @return boolean
     */
    protected function _tag_close_END_LAST_PAGE($param)
    {
        return true;
    }


Le placement du bloc de fin marche très bien, par contre la modification de la hauteur du tableau principal ne fonctionne pas. Je ne sais pas si toucher cette variable est le bon moyen d'arriver à mes fins. Peut-être qu'il faudrait relancer une passe sur ce tableau pour reconstruire le PDF après avoir effectué cette modification. Bref, avez-vous une idée ? Une piste ?

Merci d'avance pour votre aide smile