예제 #1
0
 public function generateHtml2pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array())
 {
     // define("MAX_FREE_FRACTION", 1);
     define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
     G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
     require_once PATH_THIRDPARTY . 'html2pdf/html2pdf.class.php';
     // define Save file
     $sOutput = 2;
     $sOrientation = $sLandscape == false ? 'P' : 'L';
     $sLang = defined('SYS_LANG') ? SYS_LANG : 'en';
     $sMedia = $aProperties['media'];
     // margin define
     define("MINIMAL_MARGIN", 15);
     $marges = array(MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN, MINIMAL_MARGIN);
     if (isset($aProperties['margins'])) {
         // Default marges (left, top, right, bottom)
         $margins = $aProperties['margins'];
         $margins['left'] = $margins['left'] > 0 ? $margins['left'] : MINIMAL_MARGIN;
         $margins['top'] = $margins['top'] > 0 ? $margins['top'] : MINIMAL_MARGIN;
         $margins['right'] = $margins['right'] > 0 ? $margins['right'] : MINIMAL_MARGIN;
         $margins['bottom'] = $margins['bottom'] > 0 ? $margins['bottom'] : MINIMAL_MARGIN;
         $marges = array($margins['left'], $margins['top'], $margins['right'], $margins['bottom']);
     }
     $html2pdf = new HTML2PDF($sOrientation, $sMedia, $sLang, true, 'UTF-8', $marges);
     $html2pdf->pdf->SetAuthor($aFields['USR_USERNAME']);
     $html2pdf->pdf->SetTitle('Processmaker');
     $html2pdf->pdf->SetSubject($sFilename);
     $html2pdf->pdf->SetCompression(true);
     //$html2pdf->pdf->SetKeywords('HTML2PDF, TCPDF, processmaker');
     if (isset($aProperties['pdfSecurity'])) {
         $pdfSecurity = $aProperties['pdfSecurity'];
         $userPass = G::decrypt($pdfSecurity['openPassword'], $sUID);
         $ownerPass = $pdfSecurity['ownerPassword'] != '' ? G::decrypt($pdfSecurity['ownerPassword'], $sUID) : null;
         $permissions = explode("|", $pdfSecurity['permissions']);
         $html2pdf->pdf->SetProtection($permissions, $userPass, $ownerPass);
     }
     $html2pdf->setTestTdInOnePage(false);
     $html2pdf->setTestIsImage(false);
     $html2pdf->setTestIsDeprecated(false);
     $html2pdf->writeHTML($html2pdf->getHtmlFromPage($sContent));
     switch ($sOutput) {
         case 0:
             // Vrew browser
             $html2pdf->Output($sPath . $sFilename . '.pdf', 'I');
             break;
         case 1:
             // Donwnload
             $html2pdf->Output($sPath . $sFilename . '.pdf', 'D');
             break;
         case 2:
             // Save file
             $html2pdf->Output($sPath . $sFilename . '.pdf', 'F');
             break;
     }
     copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
     copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
     unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
     unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
 }
예제 #2
0
<?php

/**
 * Logiciel : exemple d'utilisation de HTML2PDF
 * 
 * Convertisseur HTML => PDF
 * Distribué sous la licence LGPL. 
 *
 * @author		Laurent MINGUET <*****@*****.**>
 *
 * setTestTdInOnePage : permet de desactiver le test sur la taille des TD afin qu'ils rentrent sur une seule page
 * 
 * isset($_GET['vuehtml']) n'est pas obligatoire
 * il permet juste d'afficher le résultat au format HTML
 * si le paramètre 'vuehtml' est passé en paramètre _GET
 */
// récupération du contenu HTML
ob_start();
include dirname(__FILE__) . '/res/exemple11.php';
$content = ob_get_clean();
// conversion HTML => PDF
require_once dirname(__FILE__) . '/../html2pdf.class.php';
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->setTestTdInOnePage(false);
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output('exemple11.pdf');
예제 #3
0
		/**
		* création d'un sous HTML2PDF pour la gestion des tableaux imbriqués
		*
		* @param	HTML2PDF	futur sous HTML2PDF passé en référence pour création
		* @param	integer		marge eventuelle de l'objet si simulation d'un TD
		* @return	null
		*/		
		function CreateSubHTML(&$sub_html, $cellmargin=0)
		{
			// initialisation du sous objet
			$sub_html = new HTML2PDF(
										$this->sens,
										$this->format,
										$this->langue,
										array($this->defaultLeft,$this->defaultTop,$this->defaultRight,$this->defaultBottom),
										true
									);
			$sub_html->isSubPart = true;
			$sub_html->setTestTdInOnePage($this->testTDin1page);
			
			$sub_html->style->css			= $this->style->css;
			$sub_html->style->css_keys		= $this->style->css_keys;
			$sub_html->style->table			= $this->style->table;
			$sub_html->style->value			= $this->style->value;
			$sub_html->style->value['text-align'] = 'left';
			$sub_html->defLIST				= $this->defLIST;
			$sub_html->style->onlyLeft = true;
			
			// initialisation de la largeur
			if ($this->style->value['width'])
			{
				$marge = $cellmargin*2;
				$marge+= $this->style->value['padding']['l'] + $this->style->value['padding']['r'];
				$marge+= $this->style->value['border']['l']['width'] + $this->style->value['border']['r']['width'];
				$marge = $sub_html->pdf->w - $this->style->value['width'] + $marge;
			}
			else
				$marge = $this->margeLeft+$this->margeRight;

			$sub_html->saveMargin(0, 0, $marge);

			// initialisation des fontes
			$sub_html->pdf->fonts		= &$this->pdf->fonts;
			$sub_html->pdf->FontFiles	= &$this->pdf->FontFiles;
			$sub_html->pdf->diffs		= &$this->pdf->diffs;

			// initialisation des positions et autre
			$sub_html->maxX = 0;
			$sub_html->maxY = 0;
			$sub_html->maxH = 0;
			$sub_html->pdf->setX(0);
			$sub_html->pdf->setY(0);
			$sub_html->style->FontSet();
		}
예제 #4
0
 /**
  * création d'un sous HTML2PDF pour la gestion des tableaux imbriqués
  *
  * @param	HTML2PDF	futur sous HTML2PDF passé en référence pour création
  * @param	integer		marge eventuelle de l'objet si simulation d'un TD
  * @return	null
  */
 function createSubHTML(&$sub_html, $cellmargin = 0)
 {
     // calcul de la largueur
     if ($this->style->value['width']) {
         $marge = $cellmargin * 2;
         $marge += $this->style->value['padding']['l'] + $this->style->value['padding']['r'];
         $marge += $this->style->value['border']['l']['width'] + $this->style->value['border']['r']['width'];
         $marge = $this->pdf->getW() - $this->style->value['width'] + $marge;
     } else {
         $marge = $this->margeLeft + $this->margeRight;
     }
     //clonage
     $sub_html = new HTML2PDF($this->sens, $this->format, $this->langue, array($this->defaultLeft, $this->defaultTop, $this->defaultRight, $this->defaultBottom));
     $sub_html->setIsSubPart();
     $sub_html->setEncoding($this->encoding);
     $sub_html->setTestTdInOnePage($this->testTDin1page);
     $sub_html->setTestIsImage($this->testIsImage);
     $sub_html->setTestIsDeprecated($this->testIsDeprecated);
     $sub_html->setDefaultFont($this->defaultFont);
     $sub_html->style->css = $this->style->css;
     $sub_html->style->css_keys = $this->style->css_keys;
     $sub_html->pdf->cloneFontFrom($this->pdf);
     $sub_html->style->table = $this->style->table;
     $sub_html->style->value = $this->style->value;
     $sub_html->style->setOnlyLeft();
     $sub_html->setNewPage($this->format, $this->sens);
     $sub_html->initSubHtml($marge, $this->page, $this->defLIST);
     // initialisation des positions et autre
     $sub_html->maxX = 0;
     $sub_html->maxY = 0;
     $sub_html->maxH = 0;
     $sub_html->pdf->setXY(0, 0);
 }
 public function ExportFullSchedule()
 {
     $sort = $this->getRequest()->getVar('sort') ? $this->getRequest()->getVar('sort') : 'day';
     $show_desc = $this->getRequest()->getVar('show_desc') ? $this->getRequest()->getVar('show_desc') : false;
     $base = Director::protocolAndHost();
     if (is_null($this->Summit())) {
         return $this->httpError(404, 'Sorry, summit not found');
     }
     $schedule = $this->Summit()->getSchedule();
     $events = new ArrayList();
     $sort_list = false;
     foreach ($schedule as $event) {
         switch ($sort) {
             case 'day':
                 $group_label = $event->getDayLabel();
                 break;
             case 'track':
                 if (!$event->isPresentation() || !$event->Category() || !$event->Category()->Title) {
                     continue 2;
                 }
                 $group_label = $event->Category()->Title;
                 $sort_list = true;
                 break;
             case 'event_type':
                 $group_label = $event->Type->Type;
                 $sort_list = true;
                 break;
         }
         if ($group_array = $events->find('Group', $group_label)) {
             $group_array->Events->push($event);
         } else {
             $group_array = new ArrayData(array('Group' => $group_label, 'Events' => new ArrayList()));
             $group_array->Events->push($event);
             $events->push($group_array);
         }
     }
     if ($sort_list) {
         $events->sort('Group');
     }
     $html_inner = $this->renderWith(array('SummitAppMySchedulePage_pdf'), array('Schedule' => $events, 'Summit' => $this->Summit(), 'ShowDescription' => $show_desc, 'Heading' => 'Full Schedule by ' . $sort));
     $css = @file_get_contents($base . "/summit/css/summitapp-myschedule-pdf.css");
     //create pdf
     $file = FileUtils::convertToFileName('full-schedule') . '.pdf';
     $html_outer = sprintf("<html><head><style>%s</style></head><body><div class='container'>%s</div></body></html>", $css, $html_inner);
     try {
         $html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(15, 5, 15, 5));
         $html2pdf->setTestIsImage(false);
         $html2pdf->setTestTdInOnePage(false);
         $html2pdf->WriteHTML($html_outer);
         //clean output buffer
         ob_end_clean();
         $html2pdf->Output($file, "D");
     } catch (HTML2PDF_exception $e) {
         $message = array('errno' => '', 'errstr' => $e->__toString(), 'errfile' => 'SummitAppSchedPage.php', 'errline' => '', 'errcontext' => '');
         SS_Log::log($message, SS_Log::ERR);
         $this->httpError(404, 'There was an error on PDF generation!');
     }
 }
예제 #6
-1
 public function return_PDF($papers)
 {
     /*
      * подключает класс формирования PDF
      * и создаёт PDF-документ
      */
     // Имя файла
     $filename = iconv('windows-1251', 'utf-8', 'Переоформление_заявок_на_информационные ресурсы_' . implode(array($this->input->post('name_f'), $this->input->post('name_i'), $this->input->post('name_o')), "_") . '.pdf');
     // Заголовки и закрытие документа (для прохождения валидности)
     $head = $this->load->view("bids/2pdf/chainhead", array(), true);
     $aft = $this->load->view("bids/2pdf/chainaft", array(), true);
     // Формируем строковый выхлоп.
     $outfile = $head . implode($papers, "") . $aft;
     // сброс буферов
     ob_start();
     $content = ob_get_clean();
     // Подключение класса. Внимательно проследить за путями!
     require_once '/var/www/html/users-r4/2pdf/html2pdf.class.php';
     // Передаём параметры парсеру
     try {
         $html2pdf = new HTML2PDF('P', 'A4', 'en');
         $html2pdf->setTestTdInOnePage(false);
         $html2pdf->setDefaultFont('Times');
         $html2pdf->writeHTML($outfile, isset($_GET['vuehtml']));
         $html2pdf->Output($filename);
     } catch (HTML2PDF_exception $e) {
         echo $e;
         exit;
     }
 }