public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
    {
        if (!isset($this->templates[$tpl])) {
            throw new \InvalidArgumentException('Template does not exist!');
        }

        if (\is_array($x)) {
            unset($x['tpl']);
            \extract($x, EXTR_IF_EXISTS);
            /** @noinspection NotOptimalIfConditionsInspection */
            /** @noinspection CallableParameterUseCaseInTypeContextInspection */
            if (\is_array($x)) {
                $x = 0;
            }
        }

        $template = $this->templates[$tpl];

        $originalSize = $this->getTemplateSize($tpl);
        $newSize = $this->getTemplateSize($tpl, $width, $height);
        if ($adjustPageSize) {
            $this->setPageFormat($newSize, $newSize['orientation']);
        }

        $this->_out(
        // reset standard values, translate and scale
            \sprintf(
                'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q',
                ($newSize['width'] / $originalSize['width']),
                ($newSize['height'] / $originalSize['height']),
                $x * $this->k,
                ($this->h - $y - $newSize['height']) * $this->k,
                $template['id']
            )
        );

        return $newSize;
    }
public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
    {
        if (!isset($this->templates[$tpl])) {
            throw new \InvalidArgumentException('Template does not exist!');
        }

        if (\is_array($x)) {
            unset($x['tpl']);
            \extract($x, EXTR_IF_EXISTS);
            /** @noinspection NotOptimalIfConditionsInspection */
            /** @noinspection CallableParameterUseCaseInTypeContextInspection */
            if (\is_array($x)) {
                $x = 0;
            }
        }

        $template = $this->templates[$tpl];

        $originalSize = $this->getTemplateSize($tpl);
        $newSize = $this->getTemplateSize($tpl, $width, $height);
        if ($adjustPageSize) {
            $this->setPageFormat($newSize, $newSize['orientation']);
        }

        $this->_out(
        // reset standard values, translate and scale
            \sprintf(
                'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q',
                ($newSize['width'] / $originalSize['width']),
                ($newSize['height'] / $originalSize['height']),
                $x * $this->k,
                ($this->h - $y - $newSize['height']) * $this->k,
                $template['id']
            )
        );

        return $newSize;
    }
public function useTemplate ( $ tpl , $ x = 0 , $ y = 0 , $ width = null , $ height = null , $ adjustPageSize = false ) { if ( ! isset ( $ this -> templates [ $ tpl ] ) ) { throw new \ InvalidArgumentException ( 'Template does not exist!' ) ; } if ( \ is_array ( $ x ) ) { unset ( $ x [ 'tpl' ] ) ; \ extract ( $ x , EXTR_IF_EXISTS ) ; /** @noinspection NotOptimalIfConditionsInspection */ /** @noinspection CallableParameterUseCaseInTypeContextInspection */ if ( \ is_array ( $ x ) ) { $ x = 0 ; } } $ template = $ this -> templates [ $ tpl ] ; $ originalSize = $ this -> getTemplateSize ( $ tpl ) ; $ newSize = $ this -> getTemplateSize ( $ tpl , $ width , $ height ) ; if ( $ adjustPageSize ) { $ this -> setPageFormat ( $ newSize , $ newSize [ 'orientation' ] ) ; } $ this -> _out ( // reset standard values, translate and scale \ sprintf ( 'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q' , ( $ newSize [ 'width' ] / $ originalSize [ 'width' ] ) , ( $ newSize [ 'height' ] / $ originalSize [ 'height' ] ) , $ x * $ this -> k , ( $ this -> h - $ y - $ newSize [ 'height' ] ) * $ this -> k , $ template [ 'id' ] ) ) ; return $ newSize ; }
Draws a template onto the page or another template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the
aspect ratio.

@param mixed $tpl The template id
@param array|float|int $x The abscissa of upper-left corner. Alternatively you could use an assoc array
with the keys "x", "y", "width", "height", "adjustPageSize".
@param float|int $y The ordinate of upper-left corner.
@param float|int|null $width The width.
@param float|int|null $height The height.
@param bool $adjustPageSize
@return array The size
@see FpdfTplTrait::getTemplateSize()
Draws a template onto the page or another template .