dongmei8071 2019-05-15 15:27
浏览 74

TCPDF事务:空字体系列

I am using TCPDF to generate a PDF and I get the following error when i use transaction: TCPDF ERROR: Empty font family

I have the following code snippet(with transaction for pagebreak):

            $titleDesc = $sPDFQuestion;
            $pageNum = $this->pdf->PageNo();
            $this->pdf->startTransaction();

            $this->pdf->Bookmark($sPDFQuestion, 1, 0);

            $this->pdf->titleintopdf($pdfTitle, $sPDFQuestion);
            if($pageNum != $this->pdf->PageNo()){
               $this->pdf->rollbackTransaction(false);
                $this->pdf->AddPage('P', 'A4');
                $this->pdf->Bookmark($sPDFQuestion, 1, 0);
                $this->pdf->titleintopdf($pdfTitle, $sPDFQuestion);
            }
            else {
                $this->pdf->commitTransaction();
            }

This is the function titleintopdf():

    public function titleintopdf($title, $description = '')
{
    if (!empty($title)) {
        $title = $this->delete_html($title);
        $oldsize = $this->FontSizePt;
        $this->SetFontSize($oldsize + 4);
        $this->Line(5, $this->y, ($this->w - 5), $this->y);
        $this->ln(3);
        $this->MultiCell('', '', $title, '', 'C', 0);
        $this->MultiCell('', '', "Number:".$this->PageNo(), '', 'C', 0);
        if (!empty($description) && isset($description)) {
            $description = $this->delete_html($description);
            $this->ln(7);
            $this->SetFontSize($oldsize + 2);
            $this->MultiCell('', '', $description, '', 'C', 0);
            $this->ln(2);
        } else {
            $this->ln(4);
        }
        $this->MultiCell('', '', "Number:".$this->PageNo(), '', 'C', 0);

        $this->Line(5, $this->y, ($this->w - 5), $this->y);
        $this->ln(5);
        $this->SetFontSize($oldsize);
    }
}

When I don't rollback the transaction and I just commit it instead, everything works fine. I don't have a clue, why this error occurs. Do you know what the problem could be?

Greets!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?