本文整理汇总了PHP中HTML2PDF::getHtmlFromPage方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML2PDF::getHtmlFromPage方法的具体用法?PHP HTML2PDF::getHtmlFromPage怎么用?PHP HTML2PDF::getHtmlFromPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML2PDF
的用法示例。
在下文中一共展示了HTML2PDF::getHtmlFromPage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateHtml2pdf
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');
}