当前位置: 首页>>代码示例>>PHP>>正文


PHP HTML2PDF::AddFont方法代码示例

本文整理汇总了PHP中HTML2PDF::AddFont方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML2PDF::AddFont方法的具体用法?PHP HTML2PDF::AddFont怎么用?PHP HTML2PDF::AddFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTML2PDF的用法示例。


在下文中一共展示了HTML2PDF::AddFont方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: html2pdf

function html2pdf($content, $subject = NULL, $title = NULL, $type = NULL, $id = NULL, $orientation = 'P', $margins = array(5, 10, 5, 10), $save = false, $copy = false)
{
    global $layout, $DB;
    require_once LIB_DIR . '/html2pdf/html2pdf.class.php';
    if (isset($margins)) {
        if (!is_array($margins)) {
            $margins = array(5, 10, 5, 10);
        }
    }
    /* default */
    $html2pdf = new HTML2PDF($orientation, 'A4', 'en', true, 'UTF-8', $margins);
    /* disable font subsetting to improve performance */
    $html2pdf->pdf->setFontSubsetting(false);
    if ($id) {
        $info = $DB->GetRow('SELECT di.name, di.description FROM divisions di
			LEFT JOIN documents d ON (d.divisionid = di.id)
			WHERE d.id = ?', array($id));
    }
    $html2pdf->pdf->SetProducer('LMS Developers');
    $html2pdf->pdf->SetCreator('LMS ' . $layout['lmsv']);
    if ($info) {
        $html2pdf->pdf->SetAuthor($info['name']);
    }
    if ($subject) {
        $html2pdf->pdf->SetSubject($subject);
    }
    if ($title) {
        $html2pdf->pdf->SetTitle($title);
    }
    $html2pdf->pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone');
    $html2pdf->AddFont('arial', '', 'arial.php');
    $html2pdf->AddFont('arial', 'B', 'arialb.php');
    $html2pdf->AddFont('arial', 'I', 'ariali.php');
    $html2pdf->AddFont('arial', 'BI', 'arialbi.php');
    $html2pdf->AddFont('times', '', 'times.php');
    /* if tidy extension is loaded we repair html content */
    if (extension_loaded('tidy')) {
        $config = array('indent' => true, 'output-html' => true, 'indent-spaces' => 4, 'join-styles' => true, 'join-classes' => true, 'fix-bad-comments' => true, 'fix-backslash' => true, 'repeated-attributes' => 'keep-last', 'drop-proprietary-attribute' => true, 'sort-attributes' => 'alpha', 'hide-comments' => true, 'new-blocklevel-tags' => 'page, page_header, page_footer, barcode', 'wrap' => 200);
        $tidy = new tidy();
        $content = $tidy->repairString($content, $config, 'utf8');
    }
    $html2pdf->WriteHTML($content);
    if ($copy) {
        /* add watermark only for contract & annex */
        if ($type == DOC_CONTRACT || $type == DOC_ANNEX) {
            $html2pdf->AddFont('courier', '', 'courier.php');
            $html2pdf->AddFont('courier', 'B', 'courierb.php');
            $html2pdf->pdf->SetTextColor(255, 0, 0);
            $PageWidth = $html2pdf->pdf->getPageWidth();
            $PageHeight = $html2pdf->pdf->getPageHeight();
            $PageCount = $html2pdf->pdf->getNumPages();
            $txt = trim(preg_replace("/(.)/i", "\${1} ", trans('COPY')));
            $w = $html2pdf->pdf->getStringWidth($txt, 'courier', 'B', 120);
            $x = $PageWidth / 2 - $w / 2 * sin(45);
            $y = $PageHeight / 2 + 50;
            for ($i = 1; $i <= $PageCount; $i++) {
                $html2pdf->pdf->setPage($i);
                $html2pdf->pdf->SetAlpha(0.2);
                $html2pdf->pdf->SetFont('courier', 'B', 120);
                $html2pdf->pdf->StartTransform();
                $html2pdf->pdf->Rotate(45, $x, $y);
                $html2pdf->pdf->Text($x, $y, $txt);
                $html2pdf->pdf->StopTransform();
            }
            $html2pdf->pdf->SetAlpha(1);
        }
    }
    if ($type == DOC_CONTRACT || $type == DOC_ANNEX) {
        /* set signature additional information */
        $info = array('Name' => $info['name'], 'Location' => $subject, 'Reason' => $title, 'ContactInfo' => $info['description']);
        /* setup your cert & key file */
        $cert = 'file://' . LIB_DIR . '/tcpdf/config/lms.cert';
        $key = 'file://' . LIB_DIR . '/tcpdf/config/lms.key';
        /* set document digital signature & protection */
        if (file_exists($cert) && file_exists($key)) {
            $html2pdf->pdf->setSignature($cert, $key, 'lms-documents', '', 1, $info);
        }
    }
    $html2pdf->pdf->SetProtection(array('modify', 'annot-forms', 'fill-forms', 'extract', 'assemble'), '', PASSWORD_CHANGEME, '1');
    if ($save) {
        if (function_exists('mb_convert_encoding')) {
            $filename = mb_convert_encoding($title, "ISO-8859-2", "UTF-8");
        } else {
            $filename = iconv("UTF-8", "ISO-8859-2//TRANSLIT", $title);
        }
        $html2pdf->Output($filename . '.pdf', 'D');
    } else {
        $html2pdf->Output();
    }
}
开发者ID:pcela,项目名称:lms,代码行数:90,代码来源:common.php

示例2: dirname

        $html .= '<tr><td style="border: solid 1px #550000; font-family: ' . $real . ';';
        if ($type == 'b' || $type == 'bi') {
            $html .= 'font-weight: bold;';
        }
        if ($type == 'i' || $type == 'bi') {
            $html .= 'font-style: italic;';
        }
        $html .= '">abcdefghijklmnopqrstuvwxyz<br>ABCDEFGHIJKLMNOPQRSTUVWXYZ<br>0123456789</td></tr>';
    }
    $html .= '</table>';
    $html .= '</page>';
    // conversion HTML => PDF
    require_once dirname(__FILE__) . '/../html2pdf.class.php';
    $html2pdf = new HTML2PDF('P', 'A4', 'fr');
    foreach ($types as $type) {
        $html2pdf->AddFont($real, strtoupper($type), $name . $type . '.php');
    }
    $html2pdf->WriteHTML($html);
    $html2pdf->Output();
    exit;
}
?>
<html>
	<head>
		<title>Creation de fonte</title>
	</head>
	<body>
		<pre>
<?php 
echo 'Create FPDF font from TTF font : ' . $name . "\n";
echo 'Read this before using this script : <a href="http://fpdf.org/fr/tutorial/tuto7.htm">http://fpdf.org/fr/tutorial/tuto7.htm</a>' . "\n";
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:31,代码来源:index.php


注:本文中的HTML2PDF::AddFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。