Pop\Pdf\Pdf::addPage PHP Method

addPage() public method

Method to add a page to the PDF of a determined size.
public addPage ( string $sz = null, integer $w = null, integer $h = null ) : Pdf
$sz string
$w integer
$h integer
return Pdf
    public function addPage($sz = null, $w = null, $h = null)
    {
        // Define the next page and content object indices.
        $pi = $this->lastIndex($this->objects) + 1;
        $ci = $this->lastIndex($this->objects) + 2;
        // Create the page object.
        $this->objects[$pi] = new Object\Page(null, $sz, $w, $h, $pi);
        $this->objects[$pi]->content[] = $ci;
        $this->objects[$pi]->curContent = $ci;
        $this->objects[$pi]->parent = $this->parent;
        // Create the content object.
        $this->objects[$ci] = new Object\Object($ci);
        // Finalize related page variables and objects.
        $this->curPage = null === $this->curPage ? 0 : $this->lastIndex($this->pages) + 1;
        $this->pages[$this->curPage] = $pi;
        $this->objects[$this->parent]->count += 1;
        $this->objects[$this->parent]->kids[] = $pi;
        return $this;
    }

Usage Example

Exemplo n.º 1
0
    $pdf->setStrokeWidth(2, 5, 5);
    $pdf->drawRectangle(50, 150, 175, 50);
    $pdf->setPage(2);
    $pdf->setFillColor(new Rgb(12, 101, 215));
    $pdf->setStrokeColor(new Rgb(0, 0, 128));
    $pdf->setStrokeWidth(5);
    $pdf->drawRectangle(150, 650, 400, 100);
    $pdf->addFont('Courier');
    $pdf->setFillColor(new Rgb(12, 255, 12));
    $pdf->addText(10, 300, 18, 'Hello World Again!!!', 'Courier');
    $pdf->addUrl(10, 300, 380, 18, 'http://www.popphp.org/');
    $pdf->setFillColor(new Rgb(128, 200, 50));
    $pdf->setStrokeColor(new Rgb(0, 255, 0));
    $pdf->setStrokeWidth(8);
    $pdf->drawCircle(500, 500, 100);
    $pdf->addPage('Legal');
    $pdf->setFillColor(new Rgb(128, 200, 50));
    $pdf->setStrokeColor(new Rgb(0, 255, 0));
    $pdf->setStrokeWidth(8);
    $pdf->drawCircle(500, 500, 100);
    $pdf->addText(10, 300, 18, 'Hello World Again!!!', 'Courier');
    $pdf->addUrl(10, 300, 380, 18, 'http://www.google.com/');
    $pdf->addImage('../assets/images/logo-cmyk.jpg', 150, 400);
    $pdf->addLink(150, 400, 240, 100, 200, 300, 1, 1);
    $pdf->setPage(1);
    $pdf->setFillColor(new Rgb(12, 101, 215));
    $pdf->setStrokeColor(new Rgb(0, 0, 128));
    $pdf->setStrokeWidth(5);
    $pdf->drawRectangle(150, 650, 400, 100);
    $pdf->output();
} catch (\Exception $e) {
All Usage Examples Of Pop\Pdf\Pdf::addPage