Pop\Pdf\Pdf::drawRectangle PHP Method

drawRectangle() public method

Method to add a rectangle to the PDF.
public drawRectangle ( integer $x, integer $y, integer $w, integer $h = null, boolean $fill = true ) : Pdf
$x integer
$y integer
$w integer
$h integer
$fill boolean
return Pdf
    public function drawRectangle($x, $y, $w, $h = null, $fill = true)
    {
        if (null === $h) {
            $h = $w;
        }
        $co_index = $this->getContentObject();
        $this->objects[$co_index]->setStream("\n{$x} {$y} {$w} {$h} re\n" . $this->setStyle($fill) . "\n");
        return $this;
    }

Usage Example

Exemplo n.º 1
0
<?php

require_once '../../bootstrap.php';
use Pop\Color\Space\Rgb;
use Pop\Pdf\Pdf;
try {
    $pdf = new Pdf('new_test.pdf');
    $pdf->import('../assets/pdfs/hospital.pdf');
    $pdf->setFillColor(new Rgb(128, 200, 50));
    $pdf->setStrokeColor(new Rgb(0, 255, 0));
    $pdf->setStrokeWidth(8);
    $pdf->drawCircle(500, 500, 100);
    $pdf->setFillColor(new Rgb(215, 101, 12));
    $pdf->setStrokeColor(new Rgb(0, 0, 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));
All Usage Examples Of Pop\Pdf\Pdf::drawRectangle