本文整理汇总了PHP中Cezpdf::getTextWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP Cezpdf::getTextWidth方法的具体用法?PHP Cezpdf::getTextWidth怎么用?PHP Cezpdf::getTextWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cezpdf
的用法示例。
在下文中一共展示了Cezpdf::getTextWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
//.........这里部分代码省略.........
$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) {
if (empty($arrFooterLeft[$i])) {
$arrFooterLeft[$i] = '';
}
if (empty($arrFooterRight[$i])) {
$arrFooterRight[$i] = '';
}
if ($arrFooterLeft[$i] == '<--PAGENUMBER-->' || $arrFooterLeft[$i] == '[PAGENUMBER]') {
$pageNumbersX = 65;
$pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
$pageNumbersFont = $this->font_size_list;
} else {
$objPdf->addText(25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterLeft[$i]);
}
if ($arrFooterRight[$i] == '<--PAGENUMBER-->' || $arrFooterRight[$i] == '[PAGENUMBER]') {
$pageNumbersX = 595.28 - 25;
$pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
$pageNumbersFont = $this->font_size_list;
} else {
// Properly align right
$width = $objPdf->getTextWidth($this->font_size_footer, $arrFooterRight[$i]);
$objPdf->addText(595.28 - $width - 25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterRight[$i]);
}
}
$objPdf->restoreState();
$objPdf->closeObject();
$objPdf->addObject($footerForAllPages, 'all');
}
// Page numbers
if (isset($pageNumbersX)) {
$objPdf->ezStartPageNumbers($pageNumbersX, $pageNumbersY, $pageNumbersFont, '', $_ARRAYLANG['TXT_SHOP_PRICELIST_FORMAT_PAGENUMBER'], 1);
}
// Margins
$objPdf->ezSetMargins($marginTop, $marginBottom, 30, 30);
// Product table
if (isset($startpointY)) {
$objPdf->ezSetY($startpointY);
}
$objInit->backendLangId = $this->lang_id;
$_ARRAYLANG = $objInit->loadLanguageData('Shop');
Currency::setActiveCurrencyId($this->currency_id);
$currency_symbol = Currency::getActiveCurrencySymbol();
$category_ids = $this->category_ids();
if ($category_ids == '*') {
$category_ids = null;
}
$count = 1000;
// Be sensible!
// Pattern is "%" because all-empty parameters will result in an
// empty array!
$arrProduct = Products::getByShopParams($count, 0, null, $category_ids, null, '%', null, null, '`category_id` ASC, `name` ASC');
$arrCategoryName = ShopCategories::getNameArray();
$arrOutput = array();
foreach ($arrProduct as $product_id => $objProduct) {
$categoryIds = explode(',', $objProduct->category_id());
$arrCategoryNames = array();
foreach ($categoryIds as $categoryId) {
$arrCategoryNames[] = $arrCategoryName[$categoryId];
}
//$objProduct = new Product();
$arrOutput[$product_id] = array('product_name' => self::decode($objProduct->name()), 'category_name' => self::decode(implode(', ', $arrCategoryNames)), 'product_code' => self::decode($objProduct->code()), 'product_id' => self::decode($objProduct->id()), 'price' => ($objProduct->discount_active() ? "S " . Currency::formatPrice($objProduct->discountprice()) : Currency::formatPrice($objProduct->price())) . ' ' . $currency_symbol);
}
$objPdf->ezTable($arrOutput, array('product_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_NAME']) . '</b>', 'category_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_CATEGORY_NAME']) . '</b>', 'product_code' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_CODE']) . '</b>', 'product_id' => '<b>' . self::decode($_ARRAYLANG['TXT_ID']) . '</b>', 'price' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRICE']) . '</b>'), '', array('showHeadings' => 1, 'fontSize' => $this->font_size_list, 'width' => 530, 'innerLineThickness' => 0.5, 'outerLineThickness' => 0.5, 'shaded' => 2, 'shadeCol' => array(hexdec(substr($this->row_color_1, 0, 2)) / 255, hexdec(substr($this->row_color_1, 2, 2)) / 255, hexdec(substr($this->row_color_1, 4, 2)) / 255), 'shadeCol2' => array(hexdec(substr($this->row_color_2, 0, 2)) / 255, hexdec(substr($this->row_color_2, 2, 2)) / 255, hexdec(substr($this->row_color_2, 4, 2)) / 255), 'cols' => array('product_name' => array('width' => 255), 'category_name' => array('width' => 130), 'product_code' => array('width' => 50), 'product_id' => array('width' => 40, 'justification' => 'right'), 'price' => array('width' => 55, 'justification' => 'right'))));
$objPdf->ezStream();
// Never reached
return true;
}
示例2: foreach
}
$pdf->setStrokeColor(0, 0, 0);
$pdf->setLineStyle(1);
$pdf->roundedRectangle(10, 5, 170, 90, 10, $f = 0);
$pos = $y - 2 * GENERAL_LEADING;
// $address_array=explode('<br>', str_replace("\r\n", "<br>", STORE_NAME_ADDRESS));
foreach ($store_address_array as $key => $value) {
// echo $value.'<br>' ;
$pdf->addText(LEFT_MARGIN, $pos -= SMALL_LEADING, SENDER_SMALL_FONT_SIZE, $value);
}
$pdf->addText(LEFT_MARGIN, $pos -= LABEL_LINE_SPACING, ORDERIDFONTSIZE, 'Order ' . $orders['orders_id']);
$pos = $y;
if ($billing == true) {
$address_array = explode('<br>', tep_address_format($order->delivery['format_id'], $order->billing, 1, '', '<br>'));
} else {
$address_array = explode('<br>', tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'));
}
if (SHIP_FROM_COUNTRY == $address_array[count($address_array) - 1]) {
$address_array[count($address_array) - 1] = '';
}
$print_address_array = array();
foreach ($address_array as $key => $value) {
if (!is_null($value) && $value !== "") {
$fontsize = LABEL_FONT_SIZE;
while ($pdf->getTextWidth($fontsize, $value) > 160) {
$fontsize--;
}
$pdf->addText($x, $pos -= LABEL_LINE_SPACING, $fontsize, '<b>' . $value . '</b>');
}
}
}
示例3: strEzPdf
$pdf->ezSetCmMargins(2, 1.5, 1.4, 1.4);
//(top, bottom, left, right)
/*
* Define page header to be displayed on top of each page
*/
$pdf->saveState();
if ($skip_page) {
$pdf->ezNewPage();
}
$skip_page++;
$page_header = $pdf->openObject();
$pdf->selectFont("{$font_dir}/Helvetica-Bold.afm");
$ypos = $pdf->ez['pageHeight'] - (30 + $pdf->getFontHeight(12));
$doc_title = strEzPdf($projects[$project_id]['project_name'], UI_OUTPUT_RAW);
$pwidth = $pdf->ez['pageWidth'];
$xpos = round(($pwidth - $pdf->getTextWidth(12, $doc_title)) / 2, 2);
$pdf->addText($xpos, $ypos, 12, $doc_title);
$pdf->selectFont("{$font_dir}/Helvetica.afm");
$date = new w2p_Utilities_Date();
$xpos = round($pwidth - $pdf->getTextWidth(10, $date->format($df)) - $pdf->ez['rightMargin'], 2);
$doc_date = strEzPdf($date->format($df));
$pdf->addText($xpos, $ypos, 10, $doc_date);
$pdf->closeObject($page_header);
$pdf->addObject($page_header, 'all');
$gpdfkey = W2P_BASE_DIR . '/modules/tasks/images/ganttpdf_key.png';
$gpdfkeyNM = W2P_BASE_DIR . '/modules/tasks/images/ganttpdf_keyNM.png';
$pdf->ezStartPageNumbers(802, 30, 10, 'left', 'Page {PAGENUM} of {TOTALPAGENUM}');
for ($i = 0; $i < count($ganttfile); $i++) {
$gf = $ganttfile[$i];
$pdf->ezColumnsStart(array('num' => 1, 'gap' => 0));
$pdf->ezImage($gf, 0, 765, 'width', 'left');
示例4: foreach
$offsetRow = 2;
foreach ($people as $person) {
if ($pageCount > 0 && $offsetRow == 2) {
$pdf->ezNewPage();
}
for ($columnOffset = 0; $columnOffset <= 1; $columnOffset++) {
$left_edge = $left_margin + $badge_width * $columnOffset + $margin;
$right_edge = $left_edge + $badge_width - $margin * 2;
$top_edge = $top_margin + ($offsetRow + 1) * $badge_height - $margin;
$bottom_edge = $top_edge - $badge_height + $margin * 2;
$center = $left_edge + ($badge_width - $margin - $base_height / 2) / 2;
$logoY = $top_edge - $logo_height - $base_height * 1.5;
$pdf->addPngFromFile($logo_file, $left_edge + $badge_width / 2 - $logo_width / 2 - 12, $logoY, $logo_width, $logo_height);
$nameString = ucfirst($person["FIRSTNAME"]) . " " . ucfirst($person["LASTNAME"]);
$nameSize = 32;
while ($pdf->getTextWidth($nameSize, $nameString) > $badge_width - $margin * 4) {
$nameSize -= 2;
}
$nameX = $center - $pdf->getTextWidth($nameSize, $nameString) / 2;
$nameY = $logoY - $pdf->getFontHeight($nameSize) + 6;
$pdf->addText($nameX, $nameY, $nameSize, $nameString);
$institutionString = $person["INSTITUTION"];
$institutionSize = 18;
// while ($pdf->getTextWidth($institutionSize, $institutionString) > 568) {
// $institutionSize-=2;
// }
// new "guesstimated" cutoff width for resizing text
while ($pdf->getTextWidth($institutionSize, $institutionString) > 300) {
$institutionSize -= 2;
}
$institutionX = $center - $pdf->getTextWidth($institutionSize, $institutionString) / 2;