Add page number on every page
510278
def add_page_numbering
      numbering_options = {
        at: [@pdf.bounds.right - 150, 0-@format[:footer_size]],
        width: 150,
        align: :right,
        start_count_at: 1,
        color: "999999",
        size: 8
      }
      @pdf.number_pages "Page <page> of <total>", numbering_options
    end
702838
public function setTotalNumberOfPage($number = null)
    {
        if (is_null($number)) {
            $numRecords = $this->model->select($this->count().' AS '.$this->numCount)->findOne();
            $this->totalNumOfPage = $numRecords[0]->{$this->numCount};

            return $this;
        }

        $this->totalNumOfPage = $number;

        return $this;
    }
592177
def add_page(self, title=None, content=None, old_url=None,
                 tags=None, old_id=None, old_parent_id=None):
        
        if not title:
            text = decode_entities(strip_tags(content)).replace("\n", " ")
            title = text.split(". ")[0]
        if tags is None:
            tags = []
        self.pages.append({
            "title": title,
            "content": content,
            "tags": tags,
            "old_url": old_url,
            "old_id": old_id,
            "old_parent_id": old_parent_id,
        })
567026
protected function _add_page_text() {

    if ( !count($this->_page_text) )
      return;

    $this->_pdf->suspend_page("");

    for ($p = 1; $p <= $this->_page_count; $p++) {
      $this->_pdf->resume_page("pagenumber=$p");

      foreach ($this->_page_text as $pt) {
        extract($pt);

        switch ($_t) {

        case "text":
          $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
                              array($p, $this->_page_count), $text);
          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
          break;

        case "script":
          if (!$eval) {
            $eval = new PHP_Evaluator($this);
          }
          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
          break;
        }
      }

      $this->_pdf->suspend_page("");
    }

    $this->_pdf->resume_page("pagenumber=".$this->_page_number);
  }
1305268
function setPageNum($page_number) {
		$this->page = $page_number;

		if (!is_numeric($this->page) || $this->page < 1) {
			$this->page = 1;
		}

		if ($this->total !== null) {
			$this->sanitizePageNum();
		}
	}
738284
def get_page_numbers(
        current_page, num_pages,
        extremes=DEFAULT_CALLABLE_EXTREMES,
        arounds=DEFAULT_CALLABLE_AROUNDS,
        arrows=DEFAULT_CALLABLE_ARROWS):
    
    page_range = range(1, num_pages + 1)
    pages = []
    if current_page != 1:
        if arrows:
            pages.append('first')
        pages.append('previous')

    # Get first and last pages (extremes).
    first = page_range[:extremes]
    pages.extend(first)
    last = page_range[-extremes:]

    # Get the current pages (arounds).
    current_start = current_page - 1 - arounds
    if current_start < 0:
        current_start = 0
    current_end = current_page + arounds
    if current_end > num_pages:
        current_end = num_pages
    current = page_range[current_start:current_end]

    # Mix first with current pages.
    to_add = current
    if extremes:
        diff = current[0] - first[-1]
        if diff > 1:
            pages.append(None)
        elif diff < 1:
            to_add = current[abs(diff) + 1:]
    pages.extend(to_add)

    # Mix current with last pages.
    if extremes:
        diff = last[0] - current[-1]
        to_add = last
        if diff > 1:
            pages.append(None)
        elif diff < 1:
            to_add = last[abs(diff) + 1:]
        pages.extend(to_add)

    if current_page != num_pages:
        pages.append('next')
        if arrows:
            pages.append('last')
    return pages
911935
public PageFilter withPage(int pageNumber, int amountPerPage) {
        parameters.put("page", pageNumber);
        parameters.put("per_page", amountPerPage);
        return this;
    }
103885
public function setPageNumber($number)
    {
        $this->pageNumber = ($number === null ? 1 : (int)$number);
        if ($this->pageNumber < 1)
            $this->pageNumber = 1;

        return $this;
    }
1311648
public Page<E> pageNum(int pageNum) {
        //分页合理化，针对不合理的页码自动处理
        this.pageNum = ((reasonable != null && reasonable) && pageNum <= 0) ? 1 : pageNum;
        return this;
    }
1298948
private function setPerPage()
    {
        if ($this->hasInput('per_page'))
        {
            $per_page_input = $this->getInput('per_page');

            if ($this->isValidPageNumber($per_page_input)) {
                $this->perPage = $per_page_input;
            }
            else if ($per_page_input == 'all')
            {
                $this->perPage = 'all';
            }
        }
    }
28223
function makePage(number, text, isActive, isDisabled) {
        return {
          number: number,
          text: text,
          active: isActive,
          disabled: isDisabled
        };
      }
33274
def new_page(self, page_number, new_chapter, **kwargs):
        """"""
        right_template = self.document.get_page_template(self, 'right')
        left_template = self.document.get_page_template(self, 'left')
        page_template = right_template if page_number % 2 else left_template
        return page_template.page(self, page_number, self.chain, new_chapter,
                                  **kwargs)
182328
function Page(page) {
  if (!page) page = {};
  for (var key in page) this[key] = page[key];
  if (!this.hasOwnProperty('idx')) this.idx = 0;
  if (!this.hasOwnProperty('total')) this.total = 1;
  if (!this.hasOwnProperty('current')) {
    this.current = this.total;
  }
}
630476
def set_next_page_params(self):
        """"""
        if self.items:
            index = self.get_last_item_index()
            self.params[self.mode] = self.get_next_page_param(self.items[index])
719028
function (pageIndex, callback, noPageCheck) {

            if (this.$loadingPage) {
                if (callback) {
                    callback();
                }
                return;
            }
            var self = this;

            function cb(err) {
                if (callback) {
                    callback(err);
                }
                self.$loadingPage = false;
            }

            if (this.hasPage(pageIndex)) {
                this.$loadingPage = true;

                var i;
                pageIndex = pageIndex || 0;
                noPageCheck = _.isUndefined(noPageCheck) ? true : noPageCheck;

                if (!this.$.baseList || (!noPageCheck && pageIndex === this.$.page)) {
                    // nothing to do
                    cb();
                    return;
                }

                var list = this.$.list;
                var baseList = this.$.baseList;

                list.clear();

                // add items
                var startIndex = this.$.pageSize * pageIndex;
                if (baseList.$items.length > startIndex) {
                    for (i = 0; i < this.$.pageSize; i++) {
                        list.add(baseList.at(startIndex + i));
                    }
                }


                if (baseList instanceof Collection) {
                    // determinate pages to load based on the page size
                    var collectionPageSize = this.$.baseList.$.pageSize;

                    var collectionStartPage = this._itemIndexToPageIndex(this._pageIndexToItemIndex(pageIndex), collectionPageSize);
                    var collectionEndPage = this._itemIndexToPageIndex(this._pageIndexToItemIndex(pageIndex + 1) - 1, collectionPageSize);

                    var pageIndices = {};
                    for (i = collectionStartPage; i <= collectionEndPage; i++) {
                        pageIndices[i] = i;
                    }


                    flow()
                        .seq("execId", function () {
                            return ++self.$execId;
                        })
                        .parEach(pageIndices, function (pageIndex, cb) {
                            baseList.fetchPage(pageIndex, null, cb);
                        })
                        .exec(function (err, results) {

                            if (!err && results.execId == self.$execId) {
                                var items = [];
                                for (i = collectionStartPage; i <= collectionEndPage; i++) {
                                    items = items.concat(results[i].$items);
                                }

                                self._calculatePageCount();


                                var viewStartIndex = self._pageIndexToItemIndex(pageIndex, self.$.pageSize);
                                viewStartIndex -= collectionStartPage * collectionPageSize;
                                if (viewStartIndex < items.length) {
                                    // remove overlapping at start and end
                                    items = items.slice(viewStartIndex, viewStartIndex + self.$.pageSize);

                                    // and reset list
                                    self.$.list.reset(items);
                                }
                            }
                            self.set('page', pageIndex);
                            cb(err);
                        });

                } else {
                    self._calculatePageCount();
                    self.set('page', pageIndex);
                    cb();
                }
            } else {
                this._calculatePageCount();
                cb();
            }

        }
262283
function (pageNum) {
            var index = util.clamp(pageNum - 1, 0, this.numPages - 1),
                page = this.state.pages[index];
            return { top: page.y0, left: page.x0 };
        }
408382
function (pageIndex, options, callback) {

            if (pageIndex < 0) {
                throw "pageIndex must be >= 0";
            }

            var page = this.$pageCache[pageIndex];
            if (!page) {
                page = this.$pageCache[pageIndex] = new Page(null, this, pageIndex);
            }

            var self = this;
            options = _.extend(this.$, options);
            page.fetch(options, function (err, page) {
                // insert data into items if not already inserted
                if (!err && !page.itemsInsertedIntoCollection) {
                    page.itemsInsertedIntoCollection = true;

                    // add items to collection
                    self.add(page.$items, {
                        index: (pageIndex || 0) * self.$.pageSize
                    });
                }

                if (callback) {
                    callback(err, page, options);
                }
            });
        }