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


PHP pdf::SetProtection方法代码示例

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


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

示例1: customcert_generate_pdf

/**
 * Generate the PDF for the specified customcert and user.
 *
 * @param stdClass $customcert
 * @param bool $preview true if it is a preview, false otherwise
 */
function customcert_generate_pdf($customcert, $preview = false)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/pdflib.php';
    // Get the pages for the customcert, there should always be at least one page for each customcert.
    if ($pages = $DB->get_records('customcert_pages', array('customcertid' => $customcert->id), 'pagenumber ASC')) {
        // Create the pdf object.
        $pdf = new pdf();
        if (!empty($customcert->protection)) {
            $protection = explode(', ', $customcert->protection);
            $pdf->SetProtection($protection);
        }
        $pdf->setPrintHeader(false);
        $pdf->setPrintFooter(false);
        $pdf->SetTitle($customcert->name);
        $pdf->SetAutoPageBreak(true, 0);
        // Remove full-stop at the end, if it exists, to avoid "..pdf" being created and being filtered by clean_filename.
        $filename = rtrim($customcert->name, '.');
        $filename = clean_filename($filename . '.pdf');
        // Loop through the pages and display their content.
        foreach ($pages as $page) {
            // Add the page to the PDF.
            if ($page->width > $page->height) {
                $orientation = 'L';
            } else {
                $orientation = 'P';
            }
            $pdf->AddPage($orientation, array($page->width, $page->height));
            $pdf->SetMargins(0, 0, $page->margin);
            // Get the elements for the page.
            if ($elements = $DB->get_records('customcert_elements', array('pageid' => $page->id), 'sequence ASC')) {
                // Loop through and display.
                foreach ($elements as $element) {
                    // Get an instance of the element class.
                    if ($e = customcert_get_element_instance($element)) {
                        $e->render($pdf, $preview);
                    }
                }
            }
        }
        $pdf->Output($filename, 'D');
    }
}
开发者ID:rezaies,项目名称:moodle-mod_customcert,代码行数:49,代码来源:locallib.php


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