TCPDF:获取总页数/找出它是否是最后一页

时间:2012-02-02 13:17:03

标签: tcpdf

我不想在我的PDF的第一页和最后一页上使用页码,所以在我的自定义页脚功能中,我正在尝试将当前页码与总页数进行比较,这是因为$ this - > getAliasNbPages();返回一个字符串(类似“{ptp)”},不能转换为整数。

如何将总页数作为整数或以其他方式查明当前页面是否为最后一页?

2 个答案:

答案 0 :(得分:0)

您可以使用

$this->getNumPages();

答案 1 :(得分:-1)

/**
 * Reset pointer to the last document page.
 * @param $resetmargins (boolean) if true reset left, right, top margins and Y position.
 * @public
 * @since 2.0.000 (2008-01-04)
 * @see setPage(), getPage(), getNumPages()
 */
           public function lastPage($resetmargins=false) {
              $this->setPage($this->getNumPages(), $resetmargins);
           }


/**
 * Get current document page number.
 * @return int page number
 * @public
 * @since 2.1.000 (2008-01-07)
 * @see setPage(), lastpage(), getNumPages()
 */
           public function getPage() {
              return $this->page;
           }

/**
 * Get the total number of insered pages.
 * @return int number of pages
 * @public
 * @since 2.1.000 (2008-01-07)
 * @see setPage(), getPage(), lastpage()
 */
           public function getNumPages() {
              return $this->numpages;
           }

最初来自tcpdf.php你可以在那里找到它