mPDF document auto height (POS printer)

前端 未结 1 1304
遥遥无期
遥遥无期 2021-01-24 12:59

I\'m trying to create a PDF file using mPDF class and I need it to auto-height my document and not create blank spaces at bottom.

Here\'s two images of two different gen

相关标签:
1条回答
  • 2021-01-24 13:47

    Solved.

    I had one issue in my code that was creating that amount of space and it was on CSS structure.

    body { font-size: 80% }
    

    And changing to 100% solved the blank space, but I also look into the mPDF class and I found the _setPageSize() function.

    public function write($html, $url)
    {   
        /*
         * Writing and remove the content, allows the setAutoTopMargin to work
         *
         * http://www.mpdf1.com/forum/discussion/621/margin-top-problems/p1
         */
        $this->mPDF->WriteHTML($html[0]);
        $this->mPDF->page   = 0;
        $this->mPDF->state  = 0;
        unset($this->mPDF->pages[0]);
        
        // The $p needs to be passed by reference
        $p = 'P';
        $this->mPDF->_setPageSize(array(56, $this->mPDF->y), $p);
    
        foreach($html as $content)
        {
            $this->mPDF->addPage();
            $this->mPDF->WriteHTML($content);
        }
    
        $this->mPDF->Output($url);
    }
    
    0 讨论(0)
提交回复
热议问题