Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
            $argv[2] = $argv[1];
        }
    } 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;
Exemplo n.º 3
0
 public function remittanceInvoice($batch_id = 27, $shop_date_remittance = null)
 {
     $user = $this;
     $page_count = 0;
     $footer_added = 0;
     $pdf = new Zend_Pdf();
     $pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $page = $pdf->pages[$page_count];
     $style = new Zend_Pdf_Style();
     $style->setLineColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style->setFont($font, 16);
     $page->setStyle($style);
     $page_height = $page->getHeight();
     $page->drawText('RECIPIENT CREATED TAX INVOICE', 150, $page_height - 80);
     $style->setFont($font, 12);
     $page->setStyle($style);
     $company = trim($user->company) != '' ? $user->company : $user->first_name . ' ' . $user->last_name;
     $address1 = !empty($this->delivery_address1) ? $this->delivery_address1 . ' ' : null;
     $address1 .= !empty($this->delivery_address2) ? $this->delivery_address2 . ' ' : null;
     $address1 .= !empty($this->delivery_city) ? $this->delivery_city . ' ' : null;
     $address2 = !empty($this->delivery_state) ? $this->delivery_state . ', ' : null;
     $address2 .= !empty($this->delivery_postcode) ? $this->delivery_postcode : null;
     $page->drawText($company, 50, $page->getHeight() - 120);
     $page->drawText($address1, 50, $page->getHeight() - 133);
     $page->drawText($address2, 50, $page->getHeight() - 147);
     $page->drawText('ABN # ' . $this->abn, 50, $page->getHeight() - 160);
     $remittanceDate = !empty($shop_date_remittance) ? date('d/m/Y') : date('d/m/Y');
     $invoice_number = $this->id . '-' . $batch_id;
     $page->drawText('Remittance Date: ' . $remittanceDate, 400, $page->getHeight() - 120);
     $page->drawText('Invoice number: ' . $invoice_number, 400, $page->getHeight() - 133);
     $style->setFont($font, 10);
     $page->setStyle($style);
     $page->drawText('Note: only items that were sold with GST applicable will appear on this invoice', 100, $page->getHeight() - 188);
     $head_row_height = 20;
     $row_height = 20;
     $line_height_start = $page_height - 200;
     $total_data_row = 30;
     $page_break_row = 25;
     $textline_height = 12;
     $spModel = Base::getModel('Shop_Products');
     $select = $spModel->select()->setIntegrityCheck(false)->from(array('sp' => 'shop_products'));
     //join with common_items
     $select->join(array('ci' => 'common_items'), 'sp.client_product_id = ci.client_product_id', array('sum(ci.copies) as copies, sum(ci.copies*ci.shop_markup) as shop_markup,  ci.registered_gst as gst', 'ci.registered_gst'));
     $select->where('ci.remittance_batch_id = ?', $batch_id);
     if (!empty($shop_date_remittance)) {
         $select->where('ci.shop_date_remittance = ?', $shop_date_remittance);
     }
     $select->where('sp.common_user_id = ?', $user->id);
     $select->where('ci.registered_gst = 1');
     $select->group(array('sp.common_user_id', 'gst'));
     $shop_markup_inc_gst = $shop_markup_exc_gst = '';
     //Zend_Debug::dump((string)$select); die();
     $rows = $spModel->fetchAll($select);
     $total_data_row = $rows->count();
     $i = 1;
     $j = 1;
     $total_copies = 0;
     $total_Ex_GST = $total_Inc_GST = 0.0;
     foreach ($rows as $row) {
         if ($i == 1) {
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $head_row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $head_row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $head_row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $head_row_height)->drawLine(60, $line_height_start - $head_row_height, 540, $line_height_start - $head_row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $head_row_height)->drawText('Description', 68, $line_height_start - $textline_height)->drawText('Copies', 308, $line_height_start - $textline_height)->drawText('Ex-GST Amount', 368, $line_height_start - $textline_height)->drawText('Inc-GST Amount', 458, $line_height_start - $textline_height);
             // Table Headers
             $line_height_start = $line_height_start - $head_row_height;
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
             $style->setFont($font, 10);
             $page->setStyle($style);
         }
         $shop_markup = sprintf("%01.2f", $row->shop_markup);
         $shop_markup_len = strlen($shop_markup);
         $num_pad = 5 * ($shop_markup_len - 4);
         $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $row_height)->drawLine(60, $line_height_start - $row_height, 540, $line_height_start - $row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $row_height)->drawText($row->title, 68, $line_height_start - $textline_height)->drawText($row->copies, 330, $line_height_start - $textline_height)->drawText($row->gst == 1 ? sprintf("%01.2f", $shop_markup - $shop_markup / 11) : sprintf("%01.2f", $shop_markup), 425 - $num_pad, $line_height_start - $textline_height)->drawText(sprintf("%01.2f", $shop_markup), 515 - $num_pad, $line_height_start - $textline_height);
         // Table Headers
         $line_height_start = $line_height_start - $row_height;
         $total_copies += $row->copies;
         $total_Inc_GST += $shop_markup;
         if ($row->gst == 1) {
             $total_Ex_GST += $shop_markup - $shop_markup / 11;
         } else {
             $total_Ex_GST += $shop_markup;
         }
         $footer_added = 0;
         if ($j == $total_data_row) {
             $total_Ex_GST = sprintf("%01.2f", $total_Ex_GST);
             $total_Inc_GST = sprintf("%01.2f", $total_Inc_GST);
             $len = strlen($total_Ex_GST);
             $ex_gst_num_pad = 5 * ($len - 4);
             $len = strlen($total_Inc_GST);
             $inc_gst_num_pad = 5 * ($len - 4);
             $len = strlen($total_copies);
             $copies_num_pad = 5 * ($len - 1);
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $head_row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $head_row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $head_row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $head_row_height)->drawLine(60, $line_height_start - $head_row_height, 540, $line_height_start - $head_row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $head_row_height)->drawText('Total', 68, $line_height_start - $textline_height)->drawText($total_copies, 330 - $copies_num_pad, $line_height_start - $textline_height)->drawText($total_Ex_GST, 425 - $ex_gst_num_pad, $line_height_start - $textline_height)->drawText($total_Inc_GST, 515 - $inc_gst_num_pad, $line_height_start - $textline_height);
             // Table Headers
             $line_height_start = $line_height_start - $head_row_height;
             $footer_added = 1;
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
             $page->drawImage($image, 65, 40, 250, 80);
             $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
             $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
             $page->drawImage($image, 400, 40, 550, 80);
         }
         if ($i == $page_break_row) {
             if ($footer_added == 0) {
                 $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
                 $page->drawImage($image, 65, 40, 250, 80);
                 $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
                 $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
                 $page->drawImage($image, 400, 40, 550, 80);
                 $page_count++;
                 $pdf->pages[$page_count] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $page = $pdf->pages[$page_count];
                 $style = new Zend_Pdf_Style();
                 $style->setLineColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
                 $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
                 $style->setFont($font, 10);
                 $page->setStyle($style);
                 $line_height_start = $page_height - 80;
             }
             $page_break_row = 30;
             $i = 1;
         } else {
             $i++;
         }
         $j++;
     }
     if ($footer_added == 0) {
         $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
         $page->drawImage($image, 65, 40, 250, 80);
         $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
         $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
         $page->drawImage($image, 400, 40, 550, 80);
     }
     if ($total_data_row > 0) {
         $pdf->save(APPLICATION_PATH . '/../tmp/remittance_invoice/' . $invoice_number . '.pdf');
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 /**
  * Draws the cell to the PDF page.
  * 
  * This function will parse the internal $_text field and draw the cell to the PDF page.
  */
 public function write()
 {
     if (!$this->_page instanceof Zend_Pdf_Page) {
         throw new Zend_Pdf_Exception("The PDF page that the cell is attempting to write to is not a valid page.");
     }
     if (!$this->_font instanceof Zend_Pdf_Resource_Font) {
         throw new Zend_Pdf_Exception('No font has been set');
     }
     if ($this->isAutoHeight()) {
         $this->_height = $this->_autoHeight;
     }
     if ($this->isAutoWidth()) {
         $this->_width = $this->_autoWidth;
     }
     //positions of the cell's box
     //initalize the diminsions to defaults
     $top = $this->_y;
     $left = $this->_x;
     $right = $left + $this->getWidth();
     $bottom = $top + $this->getHeight();
     if ($this->_position & Zend_Pdf_Cell::POSITION_BOTTOM) {
         $top = $this->getHeight();
         $bottom = $top + $this->getHeight();
     }
     if ($this->_position & Zend_Pdf_Cell::POSITION_CENTER_X) {
         $left = $this->_page->getWidth() / 2 - $this->getWidth() / 2 + $this->_x;
         $right = $left + $this->getWidth();
     }
     if ($this->_position & Zend_Pdf_Cell::POSITION_CENTER_Y) {
         $top = $this->_page->getHeight() / 2 + $this->getHeight() / 2 - $this->_y;
         $bottom = $top - $this->getHeight();
     }
     if ($this->_position & Zend_Pdf_Cell::POSITION_TOP) {
         $top = $this->_page->getHeight();
         $bottom = $top + $this->getHeight();
     }
     if ($this->_position & Zend_Pdf_Cell::POSITION_RIGHT) {
         $left = $this->_page->getWidth() - $this->getWidth();
         $right = $left + $this->getWidth();
     }
     $currentY = $top;
     //save the page's font so we can put it back after writing the cell
     $pageFont = $this->_page->getFont();
     $fontSize = $this->_page->getFontSize();
     //restore old size and font
     $this->_page->setFont($pageFont, $fontSize);
     //draw the border
     if ($this->_border['size'] > 0) {
         $style = new Zend_Pdf_Style();
         $style->setLineColor($this->getBorderColor());
         $style->setFillColor(new Zend_Pdf_Color_RGB(255, 255, 255));
         $style->setLineDashingPattern($this->getBorderPattern());
         $this->_page->setStyle($style);
         $this->_page->drawRectangle($right, $top, $left, $bottom);
         $style->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
         $this->_page->setStyle($style);
     }
     //draw every section of every page.
     for ($i = 0; $i < count($this->_text); $i++) {
         $currentX = 0;
         switch ($this->_text[$i]['alignment']) {
             case Zend_Pdf_Cell::ALIGN_RIGHT:
                 $currentX = $right - $this->_text[$i]['width'];
                 break;
             case Zend_Pdf_Cell::ALIGN_CENTER:
                 $currentX = ($right - $left) / 2 + $left - $this->_text[$i]['width'] / 2;
                 break;
             case Zend_Pdf_Cell::ALIGN_JUSTIFY:
                 //@todo
                 break;
             default:
                 $currentX = $left;
                 break;
         }
         //add the offset
         $currentX += $this->_text[$i]['x'];
         $currentY -= $this->_text[$i]['height'];
         //count() - 4 because of the 4 properties to this text.
         for ($j = 0; $j < count($this->_text[$i]) - 4; $j++) {
             $this->_page->setFont($this->_text[$i][$j]['font'], $this->_text[$i][$j]['fontSize']);
             $this->_page->drawText($this->_text[$i][$j]['text'], $currentX, $currentY, $this->_text[$i][$j]['encoding']);
             $currentX += $this->_text[$i][$j]['width'];
         }
     }
 }
Exemplo n.º 5
0
// 3. Load PDF (Zend_PDF)
$source_filename = $media_root . $source_name . ".pdf";
$pdf = Zend_Pdf::load($source_filename);
// 4. Set metadata (Zend_PDF)
$pdf->properties['Title'] = $display_name;
$pdf->properties['Author'] = $author;
$gmt_offset = explode(":", date("P", $now));
$pdf->properties["ModDate"] = "D:" . date("YmdHis", $now) . $gmt_offset[0] . "'" . $gmt_offset[1] . "'";
// 5. Time stamp pages (Zend_PDF)
$black = new Zend_Pdf_Color_Html('#000000');
$blue = new Zend_Pdf_Color_Html('#0000FF');
$white = new Zend_Pdf_Color_Html('#FFFFFF');
$stamp = "BoTSL#" . $issue . " " . $timestamp;
$bulletin_style = new Zend_Pdf_Style();
$bulletin_style->setFillColor($white);
$bulletin_style->setLineColor($white);
$bulletin_style->setFont(Zend_Pdf_Font::fontWithPath($font_path), $font_size);
if ($smallformat == true) {
    foreach ($pdf->pages as $num => $obj) {
        $obj->setStyle($bulletin_style);
        $obj->drawRectangle(22, 24, 120, 13);
        $obj->setFillColor($black);
        $obj->drawText($stamp, 25, 17);
        // stamp
        $pdf->pages[$num] = $obj;
        // save
    }
} else {
    foreach ($pdf->pages as $num => $obj) {
        $obj->setStyle($bulletin_style);
        $obj->drawRectangle(30, 32, 150, 20);
 /**
  *  method to stamp each pdf page (add a banner with timestamp user real name and  confidentiality level)
  *  @param  void
  *  @return void
  */
 public function stamp($values)
 {
     // Prepare stamp
     if ($values != null) {
         $first = true;
         foreach ($values as $value) {
             if ($first) {
                 $sep = '';
                 $first = false;
             } else {
                 $sep = ', ';
             }
             $valueTxt = $sep . $value->getName();
         }
     } else {
         $valueTxt = '';
     }
     $text = "Downloaded on " . date("d M Y H:i", $_SERVER['REQUEST_TIME']) . " by " . $this->user->getRealName() . " " . $valueTxt;
     $stamp = $text . " // " . $text;
     // Text and box style
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     $style->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $style->setLineColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     //get pdf watermarking level based on number of pages in pdf document.
     $watermarkingLevel = $this->getWatermarkingLevelFromPdfSize();
     // Stamp with adequate watermarking level
     switch ($watermarkingLevel) {
         case self::WATERMARK_EVERYPAGE:
             // Apply it on all pages
             foreach ($this->pdf->pages as $page) {
                 $this->stampOnePage($page, $style, $stamp);
             }
             break;
         case self::WATERMARK_EVERY_TWO_PAGES:
             $count = 0;
             foreach ($this->pdf->pages as $page) {
                 if ($count % 2 == 0) {
                     $this->stampOnePage($page, $style, $stamp);
                 }
                 $count++;
             }
             break;
         case self::WATERMARK_THIRTY_PERCENT_OF_PAGES:
             $pagesToWatermark = $this->getPagesToWatermark(0.3, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
         case self::WATERMARK_TEN_PERCENT_OF_PAGES:
         default:
             $pagesToWatermark = $this->getPagesToWatermark(0.1, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
     }
 }
 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);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 public function getPdf($data)
 {
     $this->_currentPage = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $style = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style->setFont($fontH, 12);
     $color = Zend_Pdf_Color_Html::color('black');
     $style->setFillColor($color);
     $linkStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $linkStyle->setFont($fontH, 10);
     $color = Zend_Pdf_Color_Html::color('blue');
     $linkStyle->setFillColor($color);
     $linkStyle->setLineColor($color);
     $this->_initCoordinates();
     $this->addImage(Mage::getDesign()->getSkinUrl('images/logo_email.gif', array('_area' => 'frontend')), 30);
     $this->addNewLine(4);
     $helloStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $helloStyle->setFont($fontH, 14);
     $color = Zend_Pdf_Color_Html::color('black');
     $helloStyle->setFillColor($color);
     $this->addText('Hello, ' . $data->getData('email-to') . "!", $helloStyle);
     $this->addNewLine(3);
     $this->addText('You have received a ' . $data->getAmount() . ' Gift Card from ', $style);
     $fromStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
     $fromStyle->setFont($fontH, 10);
     $this->addText($data->getData('email-from'), $fromStyle);
     $this->addText("! ", $style);
     $store = Mage::getModel('core/store')->load($data->getStoreId());
     $this->addText('This card may be redeemed on ' . $store->getFrontendName() . ' website. Happy shopping!', $style);
     $this->addNewLine(1, $style->getFontSize());
     $this->addImage($data->getPicture(), 400, $this->getLineLimit());
     $this->addNewLine(5);
     $subStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $subStyle->setFont($fontH, 13);
     $color = Zend_Pdf_Color_Html::color('gray');
     $subStyle->setFillColor($color);
     $this->addText('to: ' . $data->getData('email-to'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('from: ' . $data->getData('email-from'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText("message: " . $data->getData('email-message'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('gift card value:' . $data->getAmount(), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('gift card claim code:' . $data->getCode(), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addNewLine(5);
     $subStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $subStyle->setFont($fontH, 9);
     $color = Zend_Pdf_Color_Html::color('black');
     $subStyle->setFillColor($color);
     $this->addText('To redeem and use you gift card: ', $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    1. Create an account and login into ' . $store->getUrl() . ".", $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    2. Redeem the card in My Gift Cards page of My Account section.', $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    3. Alternatively, you can redeem the card on My Cart page before proceeding to checkout.', $subStyle);
     $this->addNewLine(2, $subStyle->getFontSize());
     $this->addText('If you have any questions please contact us at ' . Mage::getStoreConfig('trans_email/ident_support/email'), $subStyle);
     $phone = $data->getData('store-phone');
     if (isset($phone)) {
         $this->addText(' or call us at ' . $phone . " Monday - Friday, 8am - 5pm PST.", $subStyle);
     }
     $this->_currentPdf = new Zend_Pdf();
     $this->_currentPdf->pages[] = $this->_currentPage;
     $this->clearTempFiles();
     return $this->_currentPdf->render();
 }