本文整理汇总了PHP中Zend_Pdf_Style::setLineWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Style::setLineWidth方法的具体用法?PHP Zend_Pdf_Style::setLineWidth怎么用?PHP Zend_Pdf_Style::setLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_Style
的用法示例。
在下文中一共展示了Zend_Pdf_Style::setLineWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setStyle
public function setStyle()
{
$style = new Zend_Pdf_Style();
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
$style->setFillColor(new Zend_Pdf_Color_Html('#333333'));
$style->setLineColor(new Zend_Pdf_Color_Html('#990033'));
$style->setLineWidth(1);
$this->_page->setStyle($style);
}
示例2: __construct
public function __construct($labels = array())
{
$cols = null;
foreach ($labels as $label) {
$col = new Core_Pdf_Table_Column();
$col->setText($label);
$cols[] = $col;
}
if ($cols) {
$this->setColumns($cols);
}
//set default alignment
$this->_align = Core_Pdf::CENTER;
//set default borders
$style = new Zend_Pdf_Style();
$style->setLineWidth(2);
$this->setBorder(Core_Pdf::BOTTOM, $style);
$this->setCellPaddings(array(5, 5, 5, 5));
//set default font
$this->_font = Zend_Pdf_Font::fontWithName(ZEND_Pdf_Font::FONT_HELVETICA_BOLD);
$this->_fontSize = 12;
}
示例3: catch
}
} else {
// Throw an exception if it's not the "Can't open file" exception
throw $e;
}
}
//------------------------------------------------------------------------------------
// Reverse page order
$pdf->pages = array_reverse($pdf->pages);
// Create new Style
$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9));
$style->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
$style->setLineWidth(3);
$style->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
try {
// Create new image object
require_once 'Zend/Pdf/Image.php';
$stampImage = Zend_Pdf_Image::imageWithPath(__DIR__ . '/stamp.jpg');
} catch (Zend_Pdf_Exception $e) {
// Example of operating with image loading exceptions.
if ($e->getMessage() != 'Image extension is not installed.' &&
$e->getMessage() != 'JPG support is not configured properly.') {
throw $e;
}
$stampImage = null;
}
示例4: drawGeneralLayout
private function drawGeneralLayout()
{
$recstyle = new Zend_Pdf_Style();
$recstyle->setLineWidth(0.5);
$this->page->setStyle($recstyle);
$this->page->drawRoundedRectangle($this->coordX(0), $this->coordY(0) - $this->mmToPts(150), $this->coordX(0) + $this->mmToPts(100), $this->coordY(0), $radius = array(15, 15, 15, 15), $fillType = Zend_Pdf_Page::SHAPE_DRAW_STROKE);
//General GLS-Layout
//x-achse | y-Achse | Länge | Dicke
$ControlBar1 = array('x' => 1, 'y' => 2, 'length' => 98, 'thick' => 1, 'horizontal' => true);
$ControlBar2 = array('x' => 1, 'y' => 15, 'length' => 98, 'thick' => 0.5, 'horizontal' => true);
$ControlBar3 = array('x' => 1, 'y' => 27.5, 'length' => 98, 'thick' => 0.5, 'horizontal' => true);
$ControlBar4 = array('x' => 1, 'y' => 56, 'length' => 98, 'thick' => 0.5, 'horizontal' => true);
$Line1 = array('x' => 1, 'y' => 62.5, 'length' => 98, 'thick' => 0.25, 'horizontal' => true);
$Line2 = array('x' => 1, 'y' => 90, 'length' => 81.5, 'thick' => 0.25, 'horizontal' => true);
$Line3 = array('x' => 1, 'y' => 119, 'length' => 81.5, 'thick' => 0.25, 'horizontal' => true);
$Line4 = array('x' => 1, 'y' => 134.5, 'length' => 98, 'thick' => 0.25, 'horizontal' => true);
$Line5 = array('x' => 1, 'y' => 62.5, 'length' => 72, 'thick' => 0.25, 'horizontal' => false);
$Line6 = array('x' => 82.5, 'y' => 62.5, 'length' => 72, 'thick' => 0.25, 'horizontal' => false);
$Line7 = array('x' => 99, 'y' => 62.5, 'length' => 72, 'thick' => 0.25, 'horizontal' => false);
$PrimaryCodeBorder1_1 = array('x' => 1, 'y' => 28.5, 'length' => 5, 'thick' => 1, 'horizontal' => true);
$PrimaryCodeBorder1_2 = array('x' => 1.5, 'y' => 28.5, 'length' => 5, 'thick' => 1, 'horizontal' => false);
$PrimaryCodeBorder2_1 = array('x' => 1, 'y' => 55, 'length' => 5, 'thick' => 1, 'horizontal' => true);
$PrimaryCodeBorder2_2 = array('x' => 1.5, 'y' => 50, 'length' => 5, 'thick' => 1, 'horizontal' => false);
$PrimaryCodeBorder3_1 = array('x' => 22.5, 'y' => 28.5, 'length' => 5, 'thick' => 1, 'horizontal' => true);
$PrimaryCodeBorder3_2 = array('x' => 27, 'y' => 28.5, 'length' => 5, 'thick' => 1, 'horizontal' => false);
$PrimaryCodeBorder4_1 = array('x' => 22.5, 'y' => 55, 'length' => 5, 'thick' => 1, 'horizontal' => true);
$PrimaryCodeBorder4_2 = array('x' => 27, 'y' => 50, 'length' => 5, 'thick' => 1, 'horizontal' => false);
$LayoutCollection = array($ControlBar1, $ControlBar2, $ControlBar3, $ControlBar4, $Line1, $Line2, $Line3, $Line4, $Line5, $Line6, $Line7, $PrimaryCodeBorder1_1, $PrimaryCodeBorder1_2, $PrimaryCodeBorder2_1, $PrimaryCodeBorder2_2, $PrimaryCodeBorder3_1, $PrimaryCodeBorder3_2, $PrimaryCodeBorder4_1, $PrimaryCodeBorder4_2);
foreach ($LayoutCollection as $element) {
// define a style
$controlLayoutStyle = new Zend_Pdf_Style();
$controlLayoutStyle->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
$controlLayoutStyle->setLineColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
$controlLayoutStyle->setLineWidth($this->mmToPts($element['thick']));
$this->page->setStyle($controlLayoutStyle);
if ($element['horizontal']) {
$this->page->drawLine($this->coordX($this->mmToPts($element['x'])), $this->coordY($this->mmToPts($element['y'])), $this->coordX($this->mmToPts($element['x']) + $this->mmToPts($element['length'])), $this->coordY($this->mmToPts($element['y'])));
} else {
$this->page->drawLine($this->coordX($this->mmToPts($element['x'])), $this->coordY($this->mmToPts($element['y'])), $this->coordX($this->mmToPts($element['x'])), $this->coordY($this->mmToPts($element['y']) + $this->mmToPts($element['length'])));
}
}
try {
// Erstelle ein neues Grafikobjekt
$imageFile = SERVER_BASE . '/images/Logo_GLS.jpg';
$stampImage = Zend_Pdf_Image::imageWithPath($imageFile);
} catch (Zend_Pdf_Exception $e) {
// Beispiel wie man mit Ladefehlern bei Grafiken umgeht.
$stampImage = null;
}
if ($stampImage != null) {
$this->page->drawImage($stampImage, $this->coordX(180), $this->coordY(0) - $this->mmToPts(149), $this->coordX($this->mmToPts(99)), $this->coordY($this->mmToPts(150)) + $this->mmToPts(14));
}
$this->page->setStyle($this->defaultStyle);
}
示例5: byProduct
public function byProduct($product, $for_catalog = false)
{
$category = $product->findManyToManyRowset("Model_DbTable_Categories", "Model_DbTable_CategoryXref")->current();
if ($category) {
$this->category = $category->getBcnName();
} else {
$this->category = "Неизвестно";
}
$productParams = $product->getParams();
if (!$for_catalog) {
$this->margins = array('top' => 35, 'right' => 20, 'bottom' => 35, 'left' => 20);
}
if (is_null($this->book)) {
$page = $this->createBook(1, $for_catalog);
} else {
$page = $this->lastPage();
}
$offset = $for_catalog == false ? 0 : $page->getHeight() - $page->getCurrentPosition() - 1;
if (!$for_catalog) {
$page->setMargins(35, 20, 35, 20);
}
$noteStyle = new Zend_Pdf_Style();
$noteStyle->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->format == 'A4' ? 6.5 : 4.5);
$noteStyle->setLineWidth($page->getWidth() - 20);
$style = new Zend_Pdf_Style();
$style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->format == 'A4' ? 8.0 : 6.5);
$style->setLineWidth($page->getWidth());
$paramsLinesCount = 0;
foreach ($productParams as $param) {
$paramsLinesCount += count(explode("\n", $param->value));
}
$paramsLinesCount++;
$subproductsModel = new Model_DbTable_Subproducts();
$select = $subproductsModel->select()->order('order ASC');
$subProducts = $product->findDependentRowset("Model_DbTable_Subproducts", 'SubproductsRel', $select);
// расчет высоты всего продукта, проверка влезает ли он на страницу, если не влезает смотрим сколько именно не влезает и есть ли субпродукты,
// которые мы може отрисовать на этой странице и перенести отстаток на другую страницу
$productHeightWithoutTable = 10 + max(array(80, $this->format == 'A4' ? $paramsLinesCount * 12 : $paramsLinesCount * 8)) + ($product->description ? $page->getTextBlockHeight(trim($product->description), $style, 3) : 0);
$productHeight = 20 + max(array(80, $this->format == 'A4' ? $paramsLinesCount * 12 : $paramsLinesCount * 8)) + ($product->description ? $page->getTextBlockHeight(trim($product->description), $style, 3) : 0) + (count($subProducts) <= 30 ? $this->format == 'A4' ? count($subProducts) * 12 + 10 : count($subProducts) * 8 + 12 + 15 : 0) + ($product->note ? $page->getTextBlockHeight($product->note, $noteStyle) + 10 : 0);
// note*/
if ($offset) {
if ($page->getHeight() - $offset - 10 < (count($subProducts) <= 30 ? $productHeight : intval($productHeight) + 40)) {
if ($page->getPageNumber() > 1) {
$page->drawCategory(isset($this->old_category) ? $this->old_category : $this->category);
$this->old_category = NULL;
$page = $this->addPage();
$offset = 0;
}
} else {
if ($page->getCurrentPosition() < 700 && $for_catalog) {
$offset -= 5;
}
$page->init($offset);
$this->old_category = $this->category;
}
} else {
$this->old_category = $this->category;
}
$this->product_page = $page->getPageNumber();
// DEBUG auto-height calculate
if (isset($_REQUEST['DEBUG'])) {
$page->drawHorizontalLine(-20, 575, $page->getHeight() - $offset, 1, new Zend_Pdf_Color_Html('green'));
$page->drawHorizontalLine(-20, 575, $page->getHeight() - $offset - $productHeight, 2, new Zend_Pdf_Color_Html('red'));
$page->drawTextBlock(count($subProducts), -20, $page->getHeight() - $offset - $productHeight);
}
// --- block / information
$page->setFont(Model_Static_Fonts::get("Franklin Gothic Demi Cond"), 14);
$page->drawTextBlock($product->sku, 5, $page->getHeight() - $offset);
$page->setFont(Model_Static_Fonts::get("Franklin Gothic Demi Cond"), 10);
$page->drawTextBlock($product->name, 5, $page->getHeight() - 10 - $offset);
// --- block / images
$images = array($product->image);
if ($product->a_images) {
$images[] = $product->a_images[0];
}
$x = 0;
if ($page->getPageNumber() % 2 == 0) {
// если картинки справа (иконки слева)
$images = array_reverse($images);
// здесь нужно посчитать правильные ширины отступов начала изображений
$x = $page->getWidth() - 5;
foreach ($images as $image) {
$sizes = $page->picSize($this->getProductImageFullpath($image), $this::IMAGE_SIZE, $this::IMAGE_SIZE, 2);
//$x = $x - $this::IMAGE_SIZE * $sizes[0];
$x = $x - $this::IMAGE_SIZE;
//echo $image." ";
}
$x = $x - 5 * (count($images) - 1);
} else {
// картинки слева - просто задаем базовый отступ по x
$x += 5;
}
//echo $x." ";
$count = 0;
// count of images (x75)
//в зависимости от задачи, выбираем папку с картинками, за это отвечает параметр $print
foreach ($images as $image) {
if ($this->print) {
//$c = $page -> drawPic(APPLICATION_ROOT . '/files/images/product_tiff/' . substr($image, 0, strripos($image, ".")).'.tif', $x, $page -> getHeight() - 20 - $offset, $this::IMAGE_SIZE, $this::IMAGE_SIZE, isset($images[1]) ? 1 : 2,1);
$c = $page->drawPic($this->getProductImageFullpath($image), $x, $page->getHeight() - 20 - $offset, $this::IMAGE_SIZE, $this::IMAGE_SIZE, 2, 1);
//.........这里部分代码省略.........
示例6: __construct
public function __construct($param1, $param2 = null, $param3 = null)
{
parent::__construct($param1, $param2, $param3);
$style = new Zend_Pdf_Style();
$style->setLineColor(new Zend_Pdf_Color_Html("#000000"));
$style->setFillColor(new Zend_Pdf_Color_Html("#000000"));
$style->setLineWidth(0.5);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER);
$style->setFont($font, 10);
$style->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
$this->_defaultStyle = $style;
$this->setStyle($style);
}
示例7: drawTable
/**
* Draw table or part of table by coordinates with or without header
*
* @param array[][] $table Table values
* @param int $x x coordinate
* @param int $y y coordinate
* @param int $width Table width
* @param int $max_y Minimal y coordinate
* @param array[] $header Table header
* @param int $start_row start row of table
*
* @return int End row
*
* @api
*/
function drawTable($table, $x, $y, $width, $max_y = 0, $header = NULL, $start_row = 0, $params = false, $note = '')
{
if (!$table) {
return NULL;
}
if ($start_row > count($table) - 1) {
if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
$this->currentPosition = $y - $this->MARGIN['bottom'];
}
return NULL;
}
$max_widths = $this->getTableColumnsMaxWidths($table, $params);
$avg_widths = $this->getTableColumnsAverageWidths($table, $params);
// parent::drawText(implode(',',$max_widths), $this -> MARGIN['left'], $this -> MARGIN['bottom'], 'UTF-8');
//вычисляем ширину столбцов, в зависимости от того, какую таблицу рисуем выбираем нужную формулу
if ($params) {
$awidth = array_sum($max_widths) - 0;
} else {
$awidth = array_sum($avg_widths) - $avg_widths[0] - 5;
$widths = array($max_widths[0]);
}
// Подгоняем ширину под заданную, через процентные соотношения
foreach ($avg_widths as $i => $a_w) {
if ($params) {
$widths[] = $a_w / $awidth * $width;
} elseif ($i != 0) {
$widths[] = $a_w / $awidth * ($width - $widths[0] - 10);
}
}
// запомним наш $x и текущий $y
$coords = array($x, $y);
// write header ( if exists )
if ($header) {
//создаем сностки для таблици с параметрами. В зависимости от количества столбцов и длинны названия параметра, заменяем его и записываем в сноски
$snoski = '';
$s_number = 1;
$widthSnoski = $width;
$this->pageFormat == 'A4' ? $countChar = 30 : ($countChar = 10);
foreach ($header as $i => $column) {
if (count($header) > 7 && strlen($column) >= $countChar && $i != 0 || $column == 'Типоразмер') {
if ($widthSnoski < $this->widthForStringUsingFontsize($s_number . '* - ' . $column . '; ', Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski) + $this->widthForStringUsingFontsize($snoski, Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski)) {
$snoski .= chr('0x0D') . chr('0x0A');
$widthSnoski *= 2;
}
$snoski .= $s_number . '* - ' . $column . '; ';
$header[$i] = $s_number . '*';
$s_number++;
} elseif ($this->pageFormat == 'A5') {
$header[$i] = str_replace('(', chr('0x0D') . chr('0x0A') . '(', $column);
}
}
$snoski .= ' ' . $note;
$this->saveGS();
$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_Html("white"));
$style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatHeader);
// Bold
$this->setStyle($style);
// calculate height of header
$height = 0;
foreach ($header as $i => $column) {
$style->setLineWidth($widths[$i]);
$height = max($height, $this->getTextBlockHeight(trim($column), $style, 0, true));
}
// if we can't write 2 line - exit
if ($y - $height - $max_y < 16) {
$this->restoreGS();
return 0;
}
// else - draw header background
$this->drawHorizontalLine($coords[0] + 5, $coords[0] + $width, $this->pageFormat == 'A4' ? $y - $height / 2 + 5.5 : $y - $height / 2 + 3.5, $height, new Zend_Pdf_Color_Html("#0095da"));
// here - write header
//
foreach ($header as $i => $col) {
$style->setLineWidth($widths[$i]);
$width_text = $this->widthForStringUsingFontsize($col, $style->getFont(), $style->getFontSize());
if ($widths[$i] > $width_text && $i != 0) {
$iLeft = $x + ($widths[$i] - $width_text) / 2;
} else {
$iLeft = $x + 8;
}
$y = min($y, $this->drawTextBlock(str_replace(array(''), array(''), trim($col)), $iLeft + 1 * ($i == 0), $coords[1] - 3, $style, 0, true));
$x += $widths[$i];
}
$this->restoreGS();
//.........这里部分代码省略.........