Returns a string which content is a PDF document
@param string $html Html content
@param array $argOptions Options for the constructor.

@return PDF file.
355288
public function generatePdf($html, array $argOptions = array())
    {
        //Calculate arguments
        $defaultOptions = array(
            'constructorArgs'      => array(),
            'writeHtmlMode'        => null,
            'writeHtmlInitialise'  => null,
            'writeHtmlClose'       => null,
            'outputFilename'       => '',
            'outputDest'           => 'S',
            'mpdf'                 => null
        );                
	
        $options = array_merge($defaultOptions, $argOptions);
        extract($options);

        if (null == $mpdf) {
            $mpdf = $this->getMpdf($constructorArgs);
        }

        //Add arguments to AddHtml function
        $writeHtmlArgs = array($writeHtmlMode, $writeHtmlInitialise, $writeHtmlClose);
        $writeHtmlArgs = array_filter($writeHtmlArgs, function($x) { 
            return !is_null($x); 
        });

        $writeHtmlArgs['html'] = $html;

        @call_user_func_array(array($mpdf, 'WriteHTML'), $writeHtmlArgs);

        //Add arguments to Output function
        $content = $mpdf->Output($outputFilename, $outputDest);
	
        return $content;
    }
541837
public function getHtml($params = array())
	{
		$html="";
		$maxValue = $this->getMaxValue(); // cette valeur va permettre de calculer l'echelle la plus pratique a utiliser
		
		$nbChiffres = pia_strlen($maxValue);
		
		$unite='1';
		for($i=0 ; $i<$nbChiffres-2 ; $i++)
		{
			$unite.='0';
		}
		
		$roundedValue = round($maxValue,-$nbChiffres+2)+$unite;
		
		
		$hauteur = 200;
		if(isset($params['hauteur']) && $params['hauteur']!='')
		{
			$hauteur = $params['hauteur'];
		}
		
		
		$colWidth=20;
		if(isset($params['colWidth']) && $params['colWidth']!='')
		{
			$colWidth=$params['colWidth'];
		}
		
		// echelle
		$heightEchelle = $hauteur;
		
		$html.="<table cellspacing=0 cellpadding=0 border=0 height=".($heightEchelle+50+50)."><tr><td valign=bottom>";
		$html.="<table border=0 cellspacing=0 cellpadding=0 style='background-color:white;' height=".($heightEchelle+50).">";
		$html.="<tr>";
		$html.="<td valign=top>";
		$html.=" <table height=$heightEchelle width=60 border=0 cellspacing=0 cellpadding=0 style=''><tr><td width=60 valign=bottom>";
		$html.="<div style='position:relative;'>";
		$html.="<div style='position:absolute;bottom:".round($heightEchelle/4)."px;left:0;width:60px;text-align:right;'>".round($roundedValue/4)."_</div>";
		$html.="<div style='position:absolute;bottom:".round($heightEchelle/2)."px;left:0;width:60px;text-align:right;'>".round($roundedValue/2)."_</div>";
		$html.="<div style='position:absolute;bottom:".round($heightEchelle/(4/3))."px;left:0;width:60px;text-align:right;'>".round($roundedValue/(4/3))."_</div>";
		$html.="<div style='position:absolute;bottom:0px;left:0;width:60px;text-align:right;'>0_</div>";
		$html.="<div style='position:absolute;bottom:".$heightEchelle."px;left:0;width:60px;text-align:right;'>".$roundedValue."_</div>";
		$html.="</div>";
		$html.="</td><td style='background-color:black;' width=2></td></tr></table>";
		$html.="</td>";
		
		foreach($this->listeValues as $indice => $value)
		{
			if(is_array($value))
			{

				if(!isset($this->listeModesAffichage[$indice]) || $this->listeModesAffichage[$indice]!='cumul')
				{
					asort($value);
				}
		
				$html.="<td valign=bottom height=200>";
				
				$html.="<table cellspacing=0 cellpadding=0 border=0  width=$colWidth style=''>";
				$valPrecedente = 0;
				$arrayHtmlGraph = array();
				foreach($value as $index => $values)
				{
					if(isset($this->listeModesAffichage[$indice]) && $this->listeModesAffichage[$indice]=='cumul')
					{
						// dans ce cas on cumul les barres , on affiche la premiere puis la seconde au dessus
						$height1 = round($value[$index]*$hauteur/$roundedValue);
						$arrayHtmlGraph[] = "<tr><td style='".$this->listeStyles[$indice][$index]."' height=".$height1."></td></tr>";
					}
					else
					{
						// dans ce cas on affiche les barres les une derriere les autres , et ont chacune comme ordonnee 0 au depart
						$height1 = round((($value[$index] - $valPrecedente) * $hauteur) / $roundedValue);
						$arrayHtmlGraph[] = "<tr><td style='".$this->listeStyles[$indice][$index]."' height=".$height1."></td></tr>";
						$valPrecedente = $value[$index] - $valPrecedente;
					}
				}
				
				// et on affiche a l'envers
				for($i=count($arrayHtmlGraph)-1 ; $i>=0 ; $i--)
				{
					$html.=$arrayHtmlGraph[$i];
				}
				
				$html.="<tr height=50><td style='background-color:white;border-top:1px solid black;font-size:9px;' valign=top>".$this->listeLibelles[$indice]."</td></tr>";//
				$html.="</table>";
				$html.="</td>";
			}
			else
			{
				$html.="<td valign=bottom height=200>";
				$height = round($value * $hauteur / $roundedValue);
				$html.="<table cellspacing=0 cellpadding=0 border=0 height=".($height+50)." width=$colWidth style='".$this->listeStyles[$indice]."'>";
				$html.="<tr>";
				$html.="<td valign=top></td>";
				$html.="</tr>";
				$html.="<tr height=50><td style='background-color:white;border-top:1px solid black;font-size:9px;' valign=top>".$this->listeLibelles[$indice]."</td></tr>";//
				$html.="</table>";
				$html.="</td>";
			}
		}
		
		$html.="</tr>";
		$html.="</table>";
		$html.="</tr>";
		$html.="</table>";
		
		
		return $html;
	}
1173555
public function getHtmlToutesLesActualites($params = array())
	{
		$html = "<h1>"._("Actualités")."</h1>";

		$d = new dateObject();
		$pagination = new paginationObject();
		$resDernieresActualites = $this->getDernieresActualites(array('sqlFields'=>'0', "returnAsMysqlRes"=>true));
		$nbEnregistrementTotaux = mysql_num_rows($resDernieresActualites);


		$nbEnregistrementsParPage=15;

		$arrayPagination=$pagination->pagination(
				array(
						'nomParamPageCourante'=>'page',
						'nbEnregistrementsParPage'=>$nbEnregistrementsParPage,
						'nbEnregistrementsTotaux'=>$nbEnregistrementTotaux,
						'typeLiens'=>'noformulaire'
				)
		);



		$arrayActus = $this->getDernieresActualites(array("sqlWhere"=>" AND desactive<>'1' ", "sqlLimit"=>"LIMIT ".mysql_real_escape_string($arrayPagination['limitSqlDebut']).", ".$nbEnregistrementsParPage));

		$tab = new tableau();

		foreach ($arrayActus as $indice => $value) {
			if ($value['urlFichier']!='') {
				$url = $value['urlFichier'];
			} else {
				$url = $this->creerUrl('', 'afficherActualite', array('archiIdActualite'=>$value['idActualite']));
			}

			$tab->addValue("<a href='".$url."'>".$d->toFrenchAffichage($value['date'])." ".stripslashes($value['titre'])."</a>");

			if ($value['photoIllustration']!='') {
				list($w, $h) = getimagesize(
						$this->getCheminPhysique()."images/actualites/".
						$value['idActualite']."/".$value['photoIllustration']
				);
				if ($w>$h) {
					$dimension = "width=80";
				} else {
					$dimension = "height=80";
				}

				$tab->addValue(
						"<img src='".$this->urlImages."actualites/".
						$value['idActualite']."/".
						$value['photoIllustration']."' $dimension>"
				);
			} else {
				$tab->addValue("&nbsp;");
			}
		}

		$html.=$arrayPagination['html'];
		$html.=$tab->createHtmlTableFromArray(
				2, 'margin:0;padding:0;', '', '', " border=''"
		);


		return $html;

	}
1005359
public function convertToString($html)
    {
        $extractedStylesheets = $this->extractExternalStylesheets($html);
        $links = $this->createStylesheetPaths($extractedStylesheets['links']);

        $externalStylesheets =  array(
            'tags' => $extractedStylesheets[0],
            'links' => $links
        );

        $html = $this->replaceExternalCss($html, $externalStylesheets);

        return $html;
    }
635507
public static function selecty($options, $selected = null, $attribs = array())
    {
        $htmls = array();
        $htmls[] = self::select(null, $attribs, false);
        if (Arr::iterable($options)) {
            foreach ($options as $value => $title) {
                $option_attribs = array('value'=>$value);
                if ((string) $selected === (string) $value) {
                    $option_attribs['selected'] = 'selected';
                }
                
                $htmls[] = self::option($title, $option_attribs);
            }
        }
        $htmls[] = '</select>';
        return join("\n", $htmls);
    }
16005
public static function navbar($content, $htmlOptions = array())
    {
        self::addCssClass('navbar', $htmlOptions);
        $display = TbArray::popValue('display', $htmlOptions);
        if (!empty($display)) {
            self::addCssClass('navbar-' . $display, $htmlOptions);
        }
        $color = TbArray::popValue('color', $htmlOptions, 'default');
        if (!empty($color)) {
            self::addCssClass('navbar-' . $color, $htmlOptions);
        }
        $htmlOptions['role'] = 'navigation';
        $output = self::openTag('nav', $htmlOptions);
        $output .= $content;
        $output .= '</nav>';
        return $output;
    }
812897
public function loadHTML($html)
    {
        $dom = new \DOMDocument();

        libxml_use_internal_errors(true);
        $dom->loadHTML($html, LIBXML_NOWARNING);
        $errors = libxml_get_errors();
        libxml_use_internal_errors(false);

        // Run through all errors
        /** @var \LibXMLError $error */
        foreach ($errors as $error) {
            throw new InvalidArgumentException(
                sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)),
                InvalidArgumentException::INVALID_HTML
            );
        }

        return $dom;
    }
1334815
protected function getHtmlDescription($html)
    {
        $content = '';
        $doc = new \DOMDocument;
        @$doc->loadHTML($html);
        $xpath = new \DOMXPath($doc);

        $query = '//p[preceding-sibling::p]';

        foreach ($xpath->query($query) as $node) {
            $content .= trim($node->textContent, PHP_EOL);
        }

        return $content;
    }
246876
public static function html() {
            $fargs = func_get_args();
            $mode = self::enabled();
            self::enabled(self::MODE_RICH);
            $ret = self::dump(empty($fargs) ? null : $fargs[0]);
            self::enabled($mode);

            return $ret;
        }
1204104
public function get($html) {
      $kernel_dir = $this->kerneldir;
      require __DIR__ . "/../Resources/config/dompdf.php";

      $this->pdf = new DOMPDF;

      foreach ($this->options as $optionKey => $optionValue) {
         $this->pdf->set_option($optionKey, $optionValue);
      }

      $this->pdf->load_html($html);
      $this->pdf->set_paper("a4", 'portrait');
      $this->pdf->render();

      $response = new Response();

      $response->setContent($this->pdf->output());
      $response->setStatusCode(200);
      $response->headers->set('Content-Type', 'application/pdf');

      return $response;
   }
312047
private function createDOMDocumentFromHTML($html = null) {

        if ($html != null) {
            libxml_use_internal_errors(true);
            $dom = new DOMDocument;
            $dom->loadHTML($html);
            libxml_clear_errors();
            libxml_use_internal_errors(false);
            return $dom;
        }
    }
352745
public function richtextInput($options = [], $pluginOptions = [], $htmlOptions = []) {
        $defaults = [
            'fontsize',
            'fontfamily',
            'fontcolor',
            'table',
            'textdirection',
            'video',
            //                        'textexpander',
            //                        'limiter',
            'filemanager',
            'imagemanager',
            //                        'clips',
            'fullscreen',
        ];
        $pluginOptions = array_replace_recursive($defaults, $pluginOptions);

        $defaults = [
            'minHeight' => 150,
            'imageUpload' => Url::to([$this->imageUploadUrl, 'attr' => $this->attribute]),
            'imageManagerJson' => Url::to([$this->imageListUrl, 'attr' => $this->attribute]),
            'fileUpload' => Url::to([$this->fileUploadUrl, 'attr' => $this->attribute]),
            'fileManagerJson' => Url::to([$this->fileListUrl, 'attr' => $this->attribute]),
            'buttonSource' => true,
            'lang' => \Yii::$app->czaHelper->getRegularLangName(),
            'plugins' => $pluginOptions,
        ];
        $options = array_replace_recursive($defaults, $options);

        $defaults = [
            'id' => isset($params['language']) ? Html::getInputId($this->model, $this->attribute) . "-{$params['language']}" : Html::getInputId($this->model, $this->attribute),
        ];
        $htmlOptions = array_replace_recursive($defaults, $htmlOptions);

        $this->adjustLabelFor($options);
        $this->parts['{input}'] = \vova07\imperavi\Widget::widget([
                    'model' => $this->model,
                    'attribute' => $this->attribute,
//                    'htmlOptions' => $htmlOptions,
                    'settings' => $options,
        ]);

        return $this;
    }
22939
public function pickURI($html)
    {
        $doc = new \DOMDocument();
        libxml_use_internal_errors(true);
        $doc->loadHTML($html);

        $xpath = new \DOMXpath($doc);

        $result = $xpath->query(
            "(//a[contains(text(), 'Bankleitzahlendateien') and contains(@href, '.txt')]/@href)[1]"
        );
        if ($result->length != 1) {
            throw new URIPickerException("Did not find download URI");

        }
        return $result->item(0)->value;
    }
692166
public function tag($name, Array $options = array(), $content = null, $open = false)
    {
        if (!$name) {
            return '';
        }
        $htmlOptions = '';
        foreach ($options as $key => $value) {
            $htmlOptions .= ' ' . $key . '="' . \htmlspecialchars($value, \ENT_COMPAT) . '"';
        }
        if ($content !== null) {
            return '<' . $name . $htmlOptions . '>' . $content . '</' . $name . '>';
        } else {
            return '<' . $name . $htmlOptions . (($open) ? '>' : ' />');
        }
    }
1217492
public static function thumbnails(array $thumbnails, $htmlOptions = array())
    {
        if (!empty($thumbnails)) {
            self::addCssClass('thumbnails', $htmlOptions);
            $defaultSpan = TbArray::popValue('span', $htmlOptions, 3);
            $output = self::openTag('ul', $htmlOptions);
            foreach ($thumbnails as $thumbnailOptions) {
                if (isset($thumbnailOptions['visible']) && $thumbnailOptions['visible'] === false) {
                    continue;
                }
                // todo: consider removing the support for htmlOptions.
                $options = TbArray::popValue('htmlOptions', $thumbnailOptions, array());
                if (!empty($options)) {
                    $thumbnailOptions = TbArray::merge($options, $thumbnailOptions);
                }
                $thumbnailOptions['itemOptions']['span'] = TbArray::popValue('span', $thumbnailOptions, $defaultSpan);
                $caption = TbArray::popValue('caption', $thumbnailOptions, '');
                $captionOptions = TbArray::popValue('captionOptions', $thumbnailOptions, array());
                self::addCssClass('caption', $captionOptions);
                $label = TbArray::popValue('label', $thumbnailOptions);
                $labelOptions = TbArray::popValue('labelOptions', $thumbnailOptions, array());
                if (!empty($label)) {
                    $caption = self::tag('h3', $labelOptions, $label) . $caption;
                }
                $content = !empty($caption) ? self::tag('div', $captionOptions, $caption) : '';
                $image = TbArray::popValue('image', $thumbnailOptions);
                $imageOptions = TbArray::popValue('imageOptions', $thumbnailOptions, array());
                $imageAlt = TbArray::popValue('alt', $imageOptions, '');
                if (!empty($image)) {
                    $content = parent::image($image, $imageAlt, $imageOptions) . $content;
                }
                $url = TbArray::popValue('url', $thumbnailOptions, false);
                $output .= $url !== false
                    ? self::thumbnailLink($content, $url, $thumbnailOptions)
                    : self::thumbnail($content, $thumbnailOptions);
            }
            $output .= '</ul>';
            return $output;
        } else {
            return '';
        }
    }
46259
public function setHtml($html)
	{
		if (is_array($html)) {
			throw new InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));
		}
		$this->removeChildren();
		$this->children[] = (string)$html;

		return $this;
	}
675347
private function getFillOpts($opts)
	{
		$this->debug->group(__CLASS__.'->'.__FUNCTION__);
		$arrayUtil = new ArrayUtil();
		$opts = $arrayUtil->mergeDeep(array(
			'output_file'	=> 'temporary',	// if null is passed, raw pdf will be returned
			'fillcolor'		=> null,		// font-color
			'checkbox_opts'	=> array(
				'fontname'		=> 'ZapfDingbats',
				'textformat'	=> 'utf16be',
				'encoding'		=> 'unicode',
				'position'		=> 'center',
				'bordercolor'	=> '#C0C0C0',	// or null
				// 'fontsize'	=> 12,
			),
			'checkbox_value'	=> "\x27\x18",
			'radio_opts'	=> array(
				'fontname'		=> 'ZapfDingbats',
				'textformat'	=> 'utf16be',
				'encoding'		=> 'unicode',
				'position'		=> 'center',
				'bordercolor'	=> '#C0C0C0',	// or null
				// 'fontsize'	=> 12,
			),
			'radio_value'	=> "\x25\xCF",
			'text_opts'		=> array(
				'bordercolor'	=> 'none',
			),
			'name_trans_func'	=> array(),			// function and parameters to transform block name
			'info' => array(),
		), $opts);
		if ($opts['output_file'] == 'temporary') {
			$temp_dir = sys_get_temp_dir();
			$opts['output_file'] = tempnam($temp_dir, 'pdf');
		}
		$this->debug->groupEnd();
		return $opts;
	}