public function render($viewFile, array $options = [])
    {
        $options = Hash::merge([
            'target' => self::TARGET_RETURN,
            'filename' => 'pdf.pdf',
        ], $options);

        $mpdf = $this->_preparePdf($viewFile, $options['viewVars']);
        $options['viewVars']['mpdf'] = $mpdf;

        if (!is_array($viewFile)) {
            $wholeString = $this->_getView()->element($viewFile, $options['viewVars']);
            // use 10% less than pcre.backtrack_limit to account for multibyte characters
            $splitLength = ini_get('pcre.backtrack_limit') - (ini_get('pcre.backtrack_limit') / 10);
            $splitString = str_split($wholeString, $splitLength);
            foreach ($splitString as $string) {
                $mpdf->WriteHTML($string);
            }
        }

        switch ($options['target']) {
            case self::TARGET_RETURN:
                return $mpdf;
                break;
            case self::TARGET_DOWNLOAD:
                $mpdf->Output($options['filename'], 'D');
                break;
            case self::TARGET_BROWSER:
                $mpdf->Output($options['filename'], 'I');
                break;
            case self::TARGET_FILE:
                $mpdf->Output($options['filename'], 'F');
                break;
            case self::TARGET_BINARY:
                return $mpdf->Output('', 'S');
                break;
            default:
                throw new \InvalidArgumentException("{$options['target']} is not a valid target");
                break;
        }
    }