当前位置: 首页>>代码示例>>PHP>>正文


PHP TCPDF_STATIC::formatTOCPageNumber方法代码示例

本文整理汇总了PHP中TCPDF_STATIC::formatTOCPageNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::formatTOCPageNumber方法的具体用法?PHP TCPDF_STATIC::formatTOCPageNumber怎么用?PHP TCPDF_STATIC::formatTOCPageNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCPDF_STATIC的用法示例。


在下文中一共展示了TCPDF_STATIC::formatTOCPageNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addHTMLTOC


//.........这里部分代码省略.........
             $pagenum = $outline['p'];
         } else {
             // placemark to be replaced with the correct number
             $pagenum = '{#' . $outline['p'] . '}';
             if ($templates['F' . $outline['l']]) {
                 $pagenum = '{' . $pagenum . '}';
             }
             $maxpage = max($maxpage, $outline['p']);
         }
         // replace templates with current values
         $row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
         $row = str_replace('#TOC_PAGE_NUMBER#', $pagenum, $row);
         // add link to page
         $row = '<a href="#' . $outline['p'] . ',' . $outline['y'] . '">' . $row . '</a>';
         // write bookmark entry
         $this->writeHTML($row, false, false, true, false, '');
     }
     // restore link styles
     $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
     $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
     // move TOC page and replace numbers
     $page_last = $this->getPage();
     $numpages = $page_last - $page_first + 1;
     // account for booklet mode
     if ($this->booklet) {
         // check if a blank page is required before TOC
         $page_fill_start = ($page_first % 2 == 0 xor $page % 2 == 0);
         $page_fill_end = !($numpages % 2 == 0 xor $page_fill_start);
         if ($page_fill_start) {
             // add a page at the end (to be moved before TOC)
             $this->addPage();
             ++$page_last;
             ++$numpages;
         }
         if ($page_fill_end) {
             // add a page at the end
             $this->addPage();
             ++$page_last;
             ++$numpages;
         }
     }
     $maxpage = max($maxpage, $page_last);
     if (!TCPDF_STATIC::empty_string($page)) {
         for ($p = $page_first; $p <= $page_last; ++$p) {
             // get page data
             $temppage = $this->getPageBuffer($p);
             for ($n = 1; $n <= $maxpage; ++$n) {
                 // update page numbers
                 $a = '{#' . $n . '}';
                 // get page number aliases
                 $pnalias = $this->getInternalPageNumberAliases($a);
                 // calculate replacement number
                 if ($n >= $page) {
                     $np = $n + $numpages;
                 } else {
                     $np = $n;
                 }
                 $na = TCPDF_STATIC::formatTOCPageNumber($this->starting_page_number + $np - 1);
                 $nu = TCPDF_FONTS::UTF8ToUTF16BE($na, false, $this->isunicode, $this->CurrentFont);
                 // replace aliases with numbers
                 foreach ($pnalias['u'] as $u) {
                     if ($correct_align) {
                         $sfill = str_repeat($filler, strlen($u) - strlen($nu . ' '));
                         if ($this->rtl) {
                             $nr = $nu . TCPDF_FONTS::UTF8ToUTF16BE(' ' . $sfill, false, $this->isunicode, $this->CurrentFont);
                         } else {
                             $nr = TCPDF_FONTS::UTF8ToUTF16BE($sfill . ' ', false, $this->isunicode, $this->CurrentFont) . $nu;
                         }
                     } else {
                         $nr = $nu;
                     }
                     $temppage = str_replace($u, $nr, $temppage);
                 }
                 foreach ($pnalias['a'] as $a) {
                     if ($correct_align) {
                         $sfill = str_repeat($filler, strlen($a) - strlen($na . ' '));
                         if ($this->rtl) {
                             $nr = $na . ' ' . $sfill;
                         } else {
                             $nr = $sfill . ' ' . $na;
                         }
                     } else {
                         $nr = $na;
                     }
                     $temppage = str_replace($a, $nr, $temppage);
                 }
             }
             // save changes
             $this->setPageBuffer($p, $temppage);
         }
         // move pages
         $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
         if ($page_fill_start) {
             $this->movePage($page_last, $page_first);
         }
         for ($i = 0; $i < $numpages; ++$i) {
             $this->movePage($page_last, $page);
         }
     }
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:101,代码来源:tcpdf.php


注:本文中的TCPDF_STATIC::formatTOCPageNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。