本文整理汇总了PHP中Cezpdf::setEncryption方法的典型用法代码示例。如果您正苦于以下问题:PHP Cezpdf::setEncryption方法的具体用法?PHP Cezpdf::setEncryption怎么用?PHP Cezpdf::setEncryption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cezpdf
的用法示例。
在下文中一共展示了Cezpdf::setEncryption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Cezpdf
error_reporting(E_ALL);
set_include_path('../src/' . PATH_SEPARATOR . get_include_path());
date_default_timezone_set('UTC');
include 'Cezpdf.php';
$pdf = new Cezpdf('a4', 'portrait');
// to test on windows xampp
if (strpos(PHP_OS, 'WIN') !== false) {
$pdf->tempPath = 'C:/temp';
}
if (!isset($_GET['nocrypt'])) {
// define the encryption mode (either RC4 40bit or RC4 128bit)
$user = isset($_GET['user']) ? $_GET['user'] : '';
$owner = isset($_GET['owner']) ? $_GET['owner'] : '';
$mode = isset($_GET['mode']) && is_numeric($_GET['mode']) ? $_GET['mode'] : 1;
$pdf->setEncryption($user, $owner, array(), $mode);
}
// select a font
$pdf->selectFont('Times-Roman');
$pdf->openHere('Fit');
$pdf->ezText("This example shows how to crypt the PDF document\n");
$pdf->ezText("\nUse \"?mode=1\" for RC4 40bit encryption\n");
$pdf->ezText("\nUse \"?mode=2\" for RC4 128bit encryption\n");
$pdf->ezText("\nUse \"?nocrypt\" to disable the encryption\n");
$pdf->ezText("\nUse \"?user=password\" to set a user password\n");
$pdf->ezText("\nUse \"?owner=password\" to set a owner password\n");
if (isset($_GET['nocrypt'])) {
$pdf->ezText("<b>Not encrypt</b> - nocrypt parameter found");
}
if (isset($_GET['d']) && $_GET['d']) {
echo $pdf->ezOutput(TRUE);
示例2: array
/**
* Creates a PDF document and sends this pricelist to the client
*
* Unfortunately, ezpdf does not return anything after printing the
* document, so there's no way to tell whether it has succeeded.
* Thus, you should not rely on the return value, except when it is
* false -- in that case, loading of some data failed.
* @return boolean False on failure, true on supposed success
*/
function send_as_pdf()
{
global $objInit, $_ARRAYLANG;
if (!$this->load()) {
return \Message::error($_ARRAYLANG['TXT_SHOP_PRICELIST_ERROR_LOADING']);
}
$objPdf = new \Cezpdf('A4');
$objPdf->setEncryption('', '', array('print'));
$objPdf->selectFont(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseLibraryPath() . '/ezpdf/fonts/' . $this->font);
$objPdf->ezSetMargins(0, 0, 0, 0);
// Reset margins
$objPdf->setLineStyle(0.5);
$marginTop = 30;
$biggerCountTop = $biggerCountBottom = 0;
$arrHeaderLeft = $arrHeaderRight = $arrFooterLeft = $arrFooterRight = array();
if ($this->header) {
// header should be shown
$arrHeaderLeft = explode("\n", $this->header_left);
$arrHeaderRight = explode("\n", $this->header_right);
$countLeft = count($arrHeaderLeft);
$countRight = count($arrHeaderRight);
$biggerCountTop = $countLeft > $countRight ? $countLeft : $countRight;
$marginTop = $biggerCountTop * 14 + 36;
}
// Bottom margin
$marginBottom = 20;
$arrFooterRight = array();
if ($this->footer) {
// footer should be shown
// Old, obsolete:
$this->footer_left = str_replace('<--DATE-->', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_left);
$this->footer_right = str_replace('<--DATE-->', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_right);
// New:
$this->footer_left = str_replace('[DATE]', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_left);
$this->footer_right = str_replace('[DATE]', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_right);
$arrFooterLeft = explode("\n", $this->footer_left);
$arrFooterRight = explode("\n", $this->footer_right);
$countLeft = count($arrFooterLeft);
$countRight = count($arrFooterRight);
$biggerCountBottom = $countLeft > $countRight ? $countLeft : $countRight;
$marginBottom = $biggerCountBottom * 20 + 20;
}
// Borders
if ($this->border) {
$linesForAllPages = $objPdf->openObject();
$objPdf->saveState();
$objPdf->setStrokeColor(0, 0, 0, 1);
$objPdf->rectangle(10, 10, 575.28, 821.89);
$objPdf->restoreState();
$objPdf->closeObject();
$objPdf->addObject($linesForAllPages, 'all');
}
// Header
$headerArray = array();
$startpointY = 0;
if ($this->header) {
$objPdf->ezSetY(830);
$headerForAllPages = $objPdf->openObject();
$objPdf->saveState();
for ($i = 0; $i < $biggerCountTop; ++$i) {
$headerArray[$i] = array('left' => isset($arrHeaderLeft[$i]) ? $arrHeaderLeft[$i] : '', 'right' => isset($arrHeaderRight[$i]) ? $arrHeaderRight[$i] : '');
}
$tempY = $objPdf->ezTable($headerArray, '', '', array('showHeadings' => 0, 'fontSize' => $this->font_size_header, 'shaded' => 0, 'width' => 540, 'showLines' => 0, 'xPos' => 'center', 'xOrientation' => 'center', 'cols' => array('right' => array('justification' => 'right'))));
$tempY -= 5;
if ($this->border) {
$objPdf->setStrokeColor(0, 0, 0);
$objPdf->line(10, $tempY, 585.28, $tempY);
}
$startpointY = $tempY - 5;
$objPdf->restoreState();
$objPdf->closeObject();
$objPdf->addObject($headerForAllPages, 'all');
}
// Footer
$pageNumbersX = $pageNumbersY = $pageNumbersFont = 0;
if ($this->footer) {
$footerForAllPages = $objPdf->openObject();
$objPdf->saveState();
$tempY = $marginBottom - 5;
if ($this->border) {
$objPdf->setStrokeColor(0, 0, 0);
$objPdf->line(10, $tempY, 585.28, $tempY);
}
// length of the longest word
$longestWord = 0;
foreach ($arrFooterRight as $line) {
if ($longestWord < strlen($line)) {
$longestWord = strlen($line);
}
}
for ($i = $biggerCountBottom - 1; $i >= 0; --$i) {
//.........这里部分代码省略.........