示例#1
3
 public function drawPDF()
 {
     $pdf = new \FPDF('L', 'mm', 'Letter');
     $pdf->SetMargins(3.175, 3.175, 3.175);
     $pdf->SetAutoPageBreak(false);
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     }
     $pdf->SetFont($this->font, '', 16);
     $data = $this->loadItems();
     $width = 136.52;
     $height = 105;
     $top = 90;
     $left = 15;
     $effective_width = $width - 2 * $left;
     foreach ($data as $item) {
         $pdf->AddPage();
         $column = 1;
         // right aligned
         $price = $this->printablePrice($item);
         $pdf->SetXY($left + $width * $column, $top);
         $pdf->SetFontSize($this->SMALL_FONT);
         $pdf->Cell($effective_width, 10, $item['brand'], 0, 1, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFontSize($this->MED_FONT);
         $pdf->MultiCell($effective_width, 12, $item['description'], 0, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFontSize($this->BIG_FONT);
         $pdf->Cell($effective_width, 25, $price, 0, 1, 'C');
         $y_pos = $pdf->GetY();
         if ($item['startDate'] != '' && $item['endDate'] != '') {
             // intl would be nice
             $datestr = $this->getDateString($item['startDate'], $item['endDate']);
             $pdf->SetXY($left + $width * $column, $top + ($height - 40));
             $pdf->SetFontSize($this->SMALL_FONT);
             $pdf->Cell($effective_width, 20, $datestr, 0, 1, 'R');
         }
         if ($item['originName'] != '') {
             $pdf->SetXY($left + $width * $column, $y_pos);
             $pdf->SetFontSize($this->SMALL_FONT);
             if (strlen($item['originName']) < 50) {
                 $pdf->Cell($effective_width, 20, $item['originName'], 0, 1, 'L');
             } else {
                 $pdf->Cell($effective_width, 20, $item['originShortName'], 0, 1, 'L');
             }
         }
     }
     $pdf->Output('WfcProdSingle.pdf', 'I');
 }
示例#2
1
 public function drawPDF()
 {
     $pdf = new \FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(0, 3.175, 0);
     $pdf->SetAutoPageBreak(false);
     define('FPDF_FONTPATH', dirname(__FILE__) . '/noauto/fonts/');
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     $pdf->AddFont('GillBook', '', 'GillSansMTPro-Book.php');
     $pdf->SetFont('Gill', '', 16);
     $data = $this->loadItems();
     $count = 0;
     $sign = 0;
     $width = 53.975;
     $height = 68.95999999999999;
     $top = 20;
     $left = 5.175;
     $effective_width = $width - 2 * $left;
     $pdf->SetDrawColor(0, 0, 0);
     $pdf->SetLineWidth(0.2);
     foreach ($data as $item) {
         if ($count % 16 == 0) {
             $pdf->AddPage();
             // draw tick marks for cutting
             $pdf->Line(2, $height + 1.5, 6, $height + 1.5);
             $pdf->Line(2, 2 * $height + 1.5, 6, 2 * $height + 1.5);
             $pdf->Line(2, 3 * $height + 1.5, 6, 3 * $height + 1.5);
             $pdf->Line($width, 2, $width, 6);
             $pdf->Line(2 * $width, 2, 2 * $width, 6);
             $pdf->Line(3 * $width, 2, 3 * $width, 6);
             $pdf->Line($width, 4 * $height - 4, $width, 4 * $height);
             $pdf->Line(2 * $width, 4 * $height - 4, 2 * $width, 4 * $height);
             $pdf->Line(3 * $width, 4 * $height - 4, 3 * $width, 4 * $height);
             $pdf->Line(4 * $width - 6, $height + 1.5, 4 * $width - 2, $height + 1.5);
             $pdf->Line(4 * $width - 6, 2 * $height + 1.5, 4 * $width - 2, 2 * $height + 1.5);
             $pdf->Line(4 * $width - 6, 3 * $height + 1.5, 4 * $width - 2, 3 * $height + 1.5);
             $sign = 0;
         }
         $row = floor($sign / 4);
         $column = $sign % 4;
         $price = $item['normal_price'];
         if ($item['scale']) {
             if (substr($price, 0, 1) != '$') {
                 $price = sprintf('$%.2f', $price);
             }
             $price .= ' /lb.';
         } elseif (isset($item['signMultiplier'])) {
             $price = $this->formatPrice($item['normal_price'], $item['signMultiplier']);
         } else {
             $price = $this->formatPrice($item['normal_price']);
         }
         $pdf->Image(dirname(__FILE__) . '/cd_head_16.png', $left - 2 + $width * $column, $top - 17 + $row * $height, $width - 6);
         $pdf->SetXY($left + $width * $column, $top + $row * $height - 2);
         $pdf->SetFont('Gill', 'B', $this->SMALL_FONT);
         $font_shrink = 0;
         while (true) {
             $pdf->SetX($left + $width * $column);
             $y = $pdf->GetY();
             $pdf->MultiCell($effective_width, 6, strtoupper($item['brand']), 0, 'C');
             if ($pdf->GetY() - $y > 6) {
                 $pdf->SetFillColor(0xff, 0xff, 0xff);
                 $pdf->Rect($left + $width * $column, $y, $left + $width * $column + $effective_width, $pdf->GetY(), 'F');
                 $font_shrink++;
                 if ($font_shrink >= $this->SMALL_FONT) {
                     break;
                 }
                 $pdf->SetFontSize($this->MED_FONT - $font_shrink);
                 $pdf->SetXY($left + $width * $column, $y);
             } else {
                 break;
             }
         }
         $pdf->SetX($left + $width * $column);
         $pdf->SetFont('Gill', '', $this->MED_FONT);
         $font_shrink = 0;
         while (true) {
             $pdf->SetX($left + $width * $column);
             $y = $pdf->GetY();
             $pdf->MultiCell($effective_width, 6, $item['description'], 0, 'C');
             if ($pdf->GetY() - $y > 12) {
                 $pdf->SetFillColor(0xff, 0xff, 0xff);
                 $pdf->Rect($left + $width * $column, $y, $left + $width * $column + $effective_width, $pdf->GetY(), 'F');
                 $font_shrink++;
                 if ($font_shrink >= $this->MED_FONT) {
                     break;
                 }
                 $pdf->SetFontSize($this->MED_FONT - $font_shrink);
                 $pdf->SetXY($left + $width * $column, $y);
             } else {
                 if ($pdf->GetY() - $y < 12) {
                     $words = explode(' ', $item['description']);
                     $multi = '';
                     for ($i = 0; $i < floor(count($words) / 2); $i++) {
                         $multi .= $words[$i] . ' ';
                     }
                     $multi = trim($multi) . "\n";
                     for ($i = floor(count($words) / 2); $i < count($words); $i++) {
                         $multi .= $words[$i] . ' ';
                     }
                     $item['description'] = trim($multi);
                     $pdf->SetFillColor(0xff, 0xff, 0xff);
                     $pdf->Rect($left + $width * $column, $y, $left + $width * $column + $effective_width, $pdf->GetY(), 'F');
                     $pdf->SetXY($left + $width * $column, $y);
                     $pdf->MultiCell($effective_width, 6, $item['description'], 0, 'C');
                 }
                 break;
             }
         }
         $pdf->SetX($left + $width * $column);
         $pdf->SetFont('GillBook', '', $this->SMALLER_FONT);
         $item['size'] = strtolower($item['size']);
         if (substr($item['size'], -1) != '.') {
             $item['size'] .= '.';
             // end abbreviation w/ period
             $item['size'] = str_replace('fz.', 'fl oz.', $item['size']);
         }
         if (substr($item['size'], 0, 1) == '.') {
             $item['size'] = '0' . $item['size'];
             // add leading zero on decimal qty
         }
         if (strlen(ltrim($item['upc'], '0')) < 5 && $item['scale']) {
             $item['size'] = 'PLU# ' . ltrim($item['upc'], '0');
             // show PLU #s on by-weight
         }
         $pdf->Cell($effective_width, 6, $item['size'], 0, 1, 'C');
         $pdf->SetXY($left + $width * $column, $top + $height * $row + ($height - $top - 18));
         $pdf->SetFont('Gill', '', $this->BIG_FONT);
         $pdf->MultiCell($effective_width, 10, $price, 0, 'C');
         if ($item['startDate'] != '' && $item['endDate'] != '') {
             // intl would be nice
             $datestr = date('M d', strtotime($item['startDate'])) . chr(0x96) . date('M d', strtotime($item['endDate']));
             $pdf->SetXY($left + $width * $column, $top + $height * $row + ($height - $top - 7));
             $pdf->SetFont('GillBook', '', $this->SMALLEST_FONT);
             $pdf->Cell($effective_width + 4, 6, strtoupper($datestr), 0, 1, 'R');
         }
         if ($item['upc'] != '') {
             $pdf->SetXY($left - 2 + $width * $column, $top + $height * $row + ($height - $top - 7));
             $pdf->SetFont('GillBook', '', $this->SMALLEST_FONT);
             $pdf->Cell($effective_width, 6, $item['upc'], 0, 1, 'L');
         }
         $pdf->Image(dirname(__FILE__) . '/' . $this->footer_image, $left - 2 + $width * $column, $top + $height * $row + ($height - $top - 2), $width - 6);
         $count++;
         $sign++;
     }
     $pdf->Output('Signage16UpP.pdf', 'I');
 }
function genpdf($typefacture, $datefacture, $nofacture, $montant, $civilite, $client, $contact, $chrono, $today)
{
    $pdf = new FPDF("P", "mm", "A4");
    $pdf->AddPage();
    $pdf->SetMargins(20, 20);
    $pdf->AddFont("Arialb", "", "arialb.php");
    //$pdf->AddFont("Courier","","arialb.php");
    /////////////////////////////////////en tete////////////////////////////////////////
    //logo
    $pdf->SetXY(18, 24);
    $X = $pdf->GetX();
    $Y = $pdf->GetY();
    $pdf->Image("img/logo.jpg", $X, $Y, 23, 19, "jpg");
    //Commune de Faa"a
    $pdf->SetXY(42, 22);
    $X = $pdf->GetX();
    $Y = $pdf->GetY();
    $pdf->SetFont("Arialb", "", 13);
    $pdf->Cell(55, 10, utf8_decode("COMMUNE DE FAA'A"));
    $pdf->SetXY($X + 1, $Y + 8);
    $pdf->SetFont("Arial", "", 12);
    $pdf->Cell(55, 5, utf8_decode("N° {$chrono}/DAF/FTR-Régie-hp"), 1, 1, "C");
    //$X=$pdf->GetX();
    $Y = $pdf->GetY();
    $pdf->SetXY($X, $Y);
    $pdf->SetFont("Arial", "", 9);
    $pdf->Cell(55, 5, utf8_decode("Affaire suivie par : Hinatini Parker"), 0, 1);
    $Y = $pdf->GetY();
    $pdf->SetXY($X, $Y);
    $pdf->SetFont("Arial", "", 9);
    $pdf->Cell(55, 3, utf8_decode("Téléphone : 800 960 poste 421"), 0, 0);
    ///////////////////////////////////fin en tete/////////////////////////////////////
    ///////////////////////////////////colonne droite/////////////////////////////////
    //Date
    $pdf->SetXY($X + 100, $Y);
    $pdf->SetFont("Arial", "", 10);
    $pdf->Cell(55, 3, "Faa'a le " . $today, 0);
    ///////////////////////////////////fin colonne droite////////////////////////////
    /////////////////////////////////info exp/dest //////////////////////////////////////
    //Le Maire
    $pdf->SetY(60);
    $pdf->SetFont("times", "", 18);
    $pdf->Cell(0, 10, "Le Maire", 0, 1, "C");
    //Destinataire
    $pdf->SetY(70);
    $pdf->SetFont("Arial", "", 10);
    $pdf->Multicell(0, 5, utf8_decode("à\n{$client}\n{$contact}"), 0, "C");
    $currentY = $pdf->GetY();
    $pdf->SetY($currentY + 10);
    $pdf->SetFont("Arialb", "U", 10);
    $pdf->Cell(20, 5, utf8_decode("Objet :"), 0, 0, "L");
    $pdf->SetFont("Arialb", "", 10);
    $pdf->Cell(0, 5, utf8_decode("Relance des factures impayées"), 0, 1, "L");
    $pdf->SetFont("Arial", "U", 10);
    $pdf->Cell(20, 5, utf8_decode("N/Réf :"), 0, 0, "L");
    $pdf->SetFont("Arial", "", 10);
    $pdf->Cell(0, 5, utf8_decode("Facture {$typefacture} N° {$nofacture} du {$datefacture}"), 0, 1, "L");
    $Y = $pdf->GetY();
    $pdf->SetY($Y + 20);
    $text = "{$civilite},\n\nJe vous informe que, sauf erreur de ma part, vous présentez un impayé " . "envers la Commune de FAA'A d'un montant de {$montant} FCP au titre de la (des) {$typefacture}.\n\n" . "Aussi, je vous demande de bien vouloir vous rapprocher de la Régie municipale pour vous acquitter de la somme due.\n\n" . "A défaut de réponse de votre part dans un délai de 45 jours à compter de la date du présent courrier," . "votre dossier sera transmis en contentieux à la Trésorerie des Iles du Vent, des Australes et des Archipels pour commandement de payer.\n\n" . "La Régie reste à votre disposition au 800.960 poste 421 pour toute entente préalable avant poursuite.\n\n" . "Je vous prie d'agréer, {$civilite}, l'expression de mes salutations distinguées";
    $pdf->Multicell(0, 5, utf8_decode($text), 0, "L");
    $pdf->Image("img/marianne.jpg", 150, 220, 31, 31, "jpg");
    ////////////////////////////////information////////////////////////////////////
    $pdf->Line(20, 273, 190, 273);
    $pdf->SetXY(20, 273);
    $pdf->SetFont("Arial", "", 7);
    $pdf->Cell(0, 3, utf8_decode("PK 4 côté mer - BP 60 002 - 98702 Faa’a Centre - Tahiti / Tél. : (689) 800 960 - Télécopie : (689) 834 890 - E-mail : mairiefaaa@mail.pf\n"), 0, 0, "C");
    ////////////////////////////////fin information////////////////////////////////////
    $pdf->Output();
}
示例#4
1
	/**
	 * Save PHPExcel to file
	 *
	 * @param 	string 		$pFileName
	 * @throws 	Exception
	 */
	public function save($pFilename = null) {
		// Open file
		global $cnf;
		$pFilename= $cnf['path']['Temp'] . $pFilename;

		$fileHandle = fopen($pFilename, 'w');
		if ($fileHandle === false) {
			throw new Exception("Could not open file $pFilename for writing.");
		}

		// Fetch sheets
		$sheets = array();
		if (is_null($this->_sheetIndex)) {
			$sheets = $this->_phpExcel->getAllSheets();
		} else {
			$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
		}

    	// PDF paper size
    	$paperSize = 'A4';

		// Create PDF
		$pdf = new FPDF('P', 'pt', $paperSize);

		// Loop all sheets
		foreach ($sheets as $sheet) {
	    	// PDF orientation
	    	$orientation = 'P';
	    	if ($sheet->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) {
		    	$orientation = 'L';
	    	}

			// Start sheet
			$pdf->SetAutoPageBreak(true);
			$pdf->SetFont('Arial', '', 10);
			$pdf->AddPage($orientation);

	    	// Get worksheet dimension
	    	$dimension = explode(':', $sheet->calculateWorksheetDimension());
	    	$dimension[0] = PHPExcel_Cell::coordinateFromString($dimension[0]);
	    	$dimension[0][0] = PHPExcel_Cell::columnIndexFromString($dimension[0][0]) - 1;
	    	$dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
	    	$dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;

	    	// Calculate column widths
	    	$sheet->calculateColumnWidths();

	    	// Loop trough cells
	    	for ($row = $dimension[0][1]; $row <= $dimension[1][1]; $row++) {
	    		// Line height
	    		$lineHeight = 0;

	    		// Calulate line height
	    		for ($column = $dimension[0][0]; $column <= $dimension[1][0]; $column++) {
	    		    $rowDimension = $sheet->getRowDimension($row);
	    			$cellHeight = PHPExcel_Shared_Drawing::pixelsToPoints(
	    				PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight())
	    			);
	    			if ($cellHeight <= 0) {
		    			$cellHeight = PHPExcel_Shared_Drawing::pixelsToPoints(
		    				PHPExcel_Shared_Drawing::cellDimensionToPixels($sheet->getDefaultRowDimension()->getRowHeight())
		    			);
	    			}
	    			if ($cellHeight <= 0) {
	    				$cellHeight = $sheet->getStyleByColumnAndRow($column, $row)->getFont()->getSize();
	    			}
	    			if ($cellHeight > $lineHeight) {
	    				$lineHeight = $cellHeight;
	    			}
	    		}

	    		// Output values
	    		for ($column = $dimension[0][0]; $column <= $dimension[1][0]; $column++) {
	    			// Start with defaults...
	    			$pdf->SetFont('Arial', '', 10);
	    			$pdf->SetTextColor(0, 0, 0);
	    			$pdf->SetDrawColor(100, 100, 100);
	    			$pdf->SetFillColor(255, 255, 255);

			    	// Coordinates
			    	$startX = $pdf->GetX();
			    	$startY = $pdf->GetY();

	    			// Cell exists?
	    			$cellData = '';
	    			if ($sheet->cellExistsByColumnAndRow($column, $row)) {
	    				if ($sheet->getCellByColumnAndRow($column, $row)->getValue() instanceof PHPExcel_RichText) {
	    					$cellData = $sheet->getCellByColumnAndRow($column, $row)->getValue()->getPlainText();
	    				} else {
		    				if ($this->_preCalculateFormulas) {
		    					$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
		    						$sheet->getCellByColumnAndRow($column, $row)->getCalculatedValue(),
		    						$sheet->getstyle( $sheet->getCellByColumnAndRow($column, $row)->getCoordinate() )->getNumberFormat()->getFormatCode()
		    					);
		    				} else {
		    					$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
		    						$sheet->getCellByColumnAndRow($column, $row)->getValue(),
		    						$sheet->getstyle( $sheet->getCellByColumnAndRow($column, $row)->getCoordinate() )->getNumberFormat()->getFormatCode()
		    					);
		    				}
	    				}
	    			}

	    			// Style information
	    			$style = $sheet->getStyleByColumnAndRow($column, $row);

	    			// Cell width
	    			$columnDimension = $sheet->getColumnDimensionByColumn($column);
	    			if ($columnDimension->getWidth() == -1) {
	    				$columnDimension->setAutoSize(true);
	    				$sheet->calculateColumnWidths(false);
	    			}
	    			$cellWidth = PHPExcel_Shared_Drawing::pixelsToPoints(
	    				PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth())
	    			);

	    			// Cell height
	    			$rowDimension = $sheet->getRowDimension($row);
	    			$cellHeight = PHPExcel_Shared_Drawing::pixelsToPoints(
	    				PHPExcel_Shared_Drawing::cellDimensionToPixels($rowDimension->getRowHeight())
	    			);
	    			if ($cellHeight <= 0) {
	    				$cellHeight = $style->getFont()->getSize();
	    			}

	    			// Column span? Rowspan?
	    			$singleCellWidth = $cellWidth;
	    			$singleCellHeight = $cellHeight;
					foreach ($sheet->getMergeCells() as $cells) {
						if ($sheet->getCellByColumnAndRow($column, $row)->isInRange($cells)) {
							list($first, ) = PHPExcel_Cell::splitRange($cells);

							if ($first == $sheet->getCellByColumnAndRow($column, $row)->getCoordinate()) {
								list($colSpan, $rowSpan) = PHPExcel_Cell::rangeDimension($cells);

								$cellWidth = $cellWidth * $colSpan;
								$cellHeight = $cellHeight * $rowSpan;
							}

							break;
						}
					}

					// Cell height OK?
					if ($cellHeight < $lineHeight) {
						$cellHeight = $lineHeight;
						$singleCellHeight = $cellHeight;
					}

	    			// Font formatting
	    			$fontStyle = '';
	    			if ($style->getFont()->getBold()) {
	    				$fontStyle .= 'B';
					}
					if ($style->getFont()->getItalic()) {
						$fontStyle .= 'I';
					}
					if ($style->getFont()->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) {
						$fontStyle .= 'U';
					}
					$pdf->SetFont('Arial', $fontStyle, $style->getFont()->getSize());

					// Text alignment
					$alignment = 'L';
					switch ($style->getAlignment()->getHorizontal()) {
						case PHPExcel_Style_Alignment::HORIZONTAL_CENTER:
							$alignment = 'C'; break;
						case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT:
							$alignment = 'R'; break;
						case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY:
							$alignment = 'J'; break;
						case PHPExcel_Style_Alignment::HORIZONTAL_LEFT:
						case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL:
						default:
							$alignment = 'L'; break;
					}

					// Text color
					$pdf->SetTextColor(
						hexdec(substr($style->getFont()->getColor()->getRGB(), 0, 2)),
						hexdec(substr($style->getFont()->getColor()->getRGB(), 2, 2)),
						hexdec(substr($style->getFont()->getColor()->getRGB(), 4, 2))
					);

					// Fill color
					if ($style->getFill()->getFillType() != PHPExcel_Style_Fill::FILL_NONE) {
						$pdf->SetFillColor(
							hexdec(substr($style->getFill()->getStartColor()->getRGB(), 0, 2)),
							hexdec(substr($style->getFill()->getStartColor()->getRGB(), 2, 2)),
							hexdec(substr($style->getFill()->getStartColor()->getRGB(), 4, 2))
						);
					}

					// Border color
					$borders = '';
	    			if ($style->getBorders()->getLeft()->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
						$borders .= 'L';
						$pdf->SetDrawColor(
							hexdec(substr($style->getBorders()->getLeft()->getColor()->getRGB(), 0, 2)),
							hexdec(substr($style->getBorders()->getLeft()->getColor()->getRGB(), 2, 2)),
							hexdec(substr($style->getBorders()->getLeft()->getColor()->getRGB(), 4, 2))
						);
					}
	    			if ($style->getBorders()->getRight()->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
						$borders .= 'R';
						$pdf->SetDrawColor(
							hexdec(substr($style->getBorders()->getRight()->getColor()->getRGB(), 0, 2)),
							hexdec(substr($style->getBorders()->getRight()->getColor()->getRGB(), 2, 2)),
							hexdec(substr($style->getBorders()->getRight()->getColor()->getRGB(), 4, 2))
						);
					}
	    			if ($style->getBorders()->getTop()->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
						$borders .= 'T';
						$pdf->SetDrawColor(
							hexdec(substr($style->getBorders()->getTop()->getColor()->getRGB(), 0, 2)),
							hexdec(substr($style->getBorders()->getTop()->getColor()->getRGB(), 2, 2)),
							hexdec(substr($style->getBorders()->getTop()->getColor()->getRGB(), 4, 2))
						);
					}
	    			if ($style->getBorders()->getBottom()->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
						$borders .= 'B';
						$pdf->SetDrawColor(
							hexdec(substr($style->getBorders()->getBottom()->getColor()->getRGB(), 0, 2)),
							hexdec(substr($style->getBorders()->getBottom()->getColor()->getRGB(), 2, 2)),
							hexdec(substr($style->getBorders()->getBottom()->getColor()->getRGB(), 4, 2))
						);
					}
					if ($borders == '') {
						$borders = 0;
					}
					if ($sheet->getShowGridlines()) {
						$borders = 'LTRB';
					}

	    			// Image?
			    	$iterator = $sheet->getDrawingCollection()->getIterator();
			    	while ($iterator->valid()) {
			    		if ($iterator->current()->getCoordinates() == PHPExcel_Cell::stringFromColumnIndex($column) . ($row + 1)) {
			    			try {
				    			$pdf->Image(
				    				$iterator->current()->getPath(),
				    				$pdf->GetX(),
				    				$pdf->GetY(),
				    				$iterator->current()->getWidth(),
				    				$iterator->current()->getHeight(),
				    				'',
				    				$this->_tempDir
				    			);
			    			} catch (Exception $ex) { }
			    		}

			    		$iterator->next();
			    	}

	    			// Print cell
	    			$pdf->MultiCell(
	    				$cellWidth,
	    				$cellHeight,
	    				$cellData,
	    				$borders,
	    				$alignment,
	    				($style->getFill()->getFillType() == PHPExcel_Style_Fill::FILL_NONE ? 0 : 1)
	    			);

			    	// Coordinates
			    	$endX = $pdf->GetX();
			    	$endY = $pdf->GetY();

			    	// Revert to original Y location
			    	if ($endY > $startY) {
			    		$pdf->SetY($startY);
			    		if ($lineHeight < $lineHeight + ($endY - $startY)) {
			    			$lineHeight = $lineHeight + ($endY - $startY);
			    		}
			    	}
			    	$pdf->SetX($startX + $singleCellWidth);

			    	// Hyperlink?
			    	if ($sheet->getCellByColumnAndRow($column, $row)->hasHyperlink()) {
			    		if (!$sheet->getCellByColumnAndRow($column, $row)->getHyperlink()->isInternal()) {
			    			$pdf->Link(
			    				$startX,
			    				$startY,
			    				$endX - $startX,
			    				$endY - $startY,
			    				$sheet->getCellByColumnAndRow($column, $row)->getHyperlink()->getUrl()
			    			);
			    		}
			    	}
				}

				// Garbage collect!
				$sheet->garbageCollect();

				// Next line...
				$pdf->Ln($lineHeight);
	    	}
		}

		// Document info
		$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
		$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
		$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
		$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
		$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());

		// Write to file
		fwrite($fileHandle, $pdf->output($pFilename, 'S'));

		// Close file
		fclose($fileHandle);
	}
 private function CreatePDFRendering($name, $company, $file)
 {
     $pdf = new FPDF('L', 'pt', array(162, 288));
     //2.25"x4"
     $pdf->AddPage();
     $pdf->SetFont('Arial', 'B', 22);
     //name font style
     $pdf->Cell(0, 22, $name, 0, 1, 'C');
     //name
     $pdf->Cell(0, 10, '', 0, 1, 'C');
     //blank line
     $pdf->SetFont('Arial', 'I', 16);
     //company font style
     $pdf->Cell(0, 16, $company, 0, 1, 'C');
     //company name
     $pdf->Cell(0, 28, '', 0, 1, 'C');
     //blank line
     $pdf->Image('images/logo.png', $pdf->GetX() + 165, $pdf->GetY(), 65);
     if ($file == true) {
         //set file name to hash of object
         $fullpath = $this->savedirectory . md5(spl_object_hash($pdf)) . '.pdf';
         $pdf->Output($fullpath, 'F');
         $pdf->Close();
         $cmd = 'lpr ' . $fullpath;
         $cmdout = shell_exec($cmd);
         return $fullpath;
     } else {
         return $pdf->Output();
     }
 }
示例#6
0
 $payment = $arRow['payments'];
 $detail = $details[$selAddW[0]][$trans];
 if (strstr($detail[0], "Gazette Ad")) {
     $gazette = True;
 }
 $lineitem = count($detail) == 1 ? $detail[0] : '(multiple items)';
 if ($lineitem == "ARPAYMEN") {
     $lineitem = "Payment Received - Thank You";
 }
 $pdf->Cell(20, 8, '', 0, 0, 'L');
 $pdf->Cell(60, 8, $date, 0, 0, 'L');
 //$pdf->Cell(40,8,date('M-d-Y',$date),0,0,'L');
 $pdf->Cell(20, 8, $trans, 0, 0, 'L');
 $pdf->Cell(25, 8, '$ ' . sprintf('%.2f', $charges), 0, 0, 'L');
 $pdf->Cell(25, 8, '$ ' . sprintf('%.2f', $payment), 0, 0, 'L');
 if ($pdf->GetY() > 265) {
     addBackPage($pdf);
     $pdf->AddPage();
 } else {
     $pdf->Ln(5);
 }
 if (!empty($lineitem)) {
     $pdf->SetFontSize(10);
     $pdf->Cell(30, 8, '', 0, 0, 'L');
     $pdf->Cell(60, 8, $lineitem, 0, 0, 'L');
     if ($pdf->GetY() > 265) {
         addBackPage($pdf);
         $pdf->AddPage();
     } else {
         $pdf->Ln(5);
     }
示例#7
0
 public function drawPDF()
 {
     $pdf = new \FPDF('L', 'mm', 'Letter');
     $pdf->SetMargins(3.175, 3.175, 3.175);
     $pdf->SetAutoPageBreak(false);
     define('FPDF_FONTPATH', dirname(__FILE__) . '/noauto/fonts/');
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     $pdf->AddFont('GillBook', '', 'GillSansMTPro-Book.php');
     $pdf->SetFont('Gill', '', 16);
     $data = $this->loadItems();
     $count = 0;
     $sign = 0;
     $width = 68.67;
     $height = 71;
     $top = 22;
     $left = 6.0;
     $effective_width = $width - $left;
     foreach ($data as $item) {
         if ($count % 12 == 0) {
             if ($count != 0) {
                 // draw tick marks again
                 // sometimes other content of the page
                 // overwrites them
                 $pdf->Line(2, $height + 0.0, 6, $height + 0.0);
                 $pdf->Line(2, 2 * $height + 1.0, 6, 2 * $height + 1.0);
                 $pdf->Line(4 * $width - 3, $height + 0.0, 4 * $width + 1, $height + 0.0);
                 $pdf->Line(4 * $width - 3, 2 * $height + 1.0, 4 * $width + 1, 2 * $height + 1.0);
                 $pdf->Line($width + 1.5, 2, $width + 1.5, 8);
                 $pdf->Line(2 * $width + 1.5, 2, 2 * $width + 1.5, 8);
                 $pdf->Line(3 * $width + 1.5, 2, 3 * $width + 1.5, 8);
                 $pdf->Line($width + 1.5, 3 * $height - 6, $width + 1.5, 3 * $height);
                 $pdf->Line(2 * $width + 1.5, 3 * $height - 6, 2 * $width + 1.5, 3 * $height);
                 $pdf->Line(3 * $width + 1.5, 3 * $height - 6, 3 * $width + 1.5, 3 * $height);
             }
             $pdf->AddPage();
             // draw tick marks for cutting
             $pdf->Line(2, $height + 0.0, 6, $height + 0.0);
             $pdf->Line(2, 2 * $height + 1.0, 6, 2 * $height + 1.0);
             $pdf->Line(4 * $width - 3, $height + 0.0, 4 * $width + 1, $height + 0.0);
             $pdf->Line(4 * $width - 3, 2 * $height + 1.0, 4 * $width + 1, 2 * $height + 1.0);
             $pdf->Line($width + 1.5, 2, $width + 1.5, 8);
             $pdf->Line(2 * $width + 1.5, 2, 2 * $width + 1.5, 8);
             $pdf->Line(3 * $width + 1.5, 2, 3 * $width + 1.5, 8);
             $pdf->Line($width + 1.5, 3 * $height - 6, $width + 1.5, 3 * $height);
             $pdf->Line(2 * $width + 1.5, 3 * $height - 6, 2 * $width + 1.5, 3 * $height);
             $pdf->Line(3 * $width + 1.5, 3 * $height - 6, 3 * $width + 1.5, 3 * $height);
             $sign = 0;
         }
         $row = floor($sign / 4);
         $column = $sign % 4;
         $price = $item['normal_price'];
         if ($item['scale']) {
             if (substr($price, 0, 1) != '$') {
                 $price = sprintf('$%.2f', $price);
             }
             $price .= ' /lb.';
         } elseif (isset($item['signMultiplier'])) {
             $price = $this->formatPrice($item['normal_price'], $item['signMultiplier']);
         } else {
             $price = $this->formatPrice($item['normal_price']);
         }
         $pdf->Image(dirname(__FILE__) . '/cd_head_16.png', $left - 1 + $width * $column, $top - 19 + $row * $height, $width - 6);
         $pdf->SetXY($left + $width * $column, $top + $row * $height + 1);
         $pdf->SetFont('Gill', 'B', $this->SMALL_FONT);
         $pdf->MultiCell($effective_width, 6, strtoupper($item['brand']), 0, 'C');
         /**
           This block attempts to write the description then
           checks how many lines it took. If the description was
           longer than two lines, it whites the whole thing out,
           drops one font size, and tries again. Calculating
           effective text size with smart line breaks seems
           really tough.
         */
         $pdf->SetFont('Gill', '', $this->MED_FONT);
         $font_shrink = 0;
         while (true) {
             $pdf->SetX($left + $width * $column);
             $y = $pdf->GetY();
             $pdf->MultiCell($effective_width, 7, $item['description'], 0, 'C');
             if ($pdf->GetY() - $y > 14) {
                 $pdf->SetFillColor(0xff, 0xff, 0xff);
                 $pdf->Rect($left + $width * $column, $y, $left + $width * $column + $effective_width, $pdf->GetY(), 'F');
                 $font_shrink++;
                 if ($font_shrink >= $this->MED_FONT) {
                     break;
                 }
                 $pdf->SetFontSize($this->MED_FONT - $font_shrink);
                 $pdf->SetXY($left + $width * $column, $y);
             } else {
                 if ($pdf->GetY() - $y < 14) {
                     $words = explode(' ', $item['description']);
                     $multi = '';
                     for ($i = 0; $i < floor(count($words) / 2); $i++) {
                         $multi .= $words[$i] . ' ';
                     }
                     $multi = trim($multi) . "\n";
                     for ($i = floor(count($words) / 2); $i < count($words); $i++) {
                         $multi .= $words[$i] . ' ';
                     }
                     $item['description'] = trim($multi);
                     $pdf->SetFillColor(0xff, 0xff, 0xff);
                     $pdf->Rect($left + $width * $column, $y, $left + $width * $column + $effective_width, $pdf->GetY(), 'F');
                     $pdf->SetXY($left + $width * $column, $y);
                     $pdf->MultiCell($effective_width, 7, $item['description'], 0, 'C');
                 }
                 break;
             }
         }
         $pdf->SetX($left + $width * $column);
         $pdf->SetFont('GillBook', '', $this->SMALLER_FONT);
         $item['size'] = strtolower($item['size']);
         if (substr($item['size'], -1) != '.') {
             $item['size'] .= '.';
             // end abbreviation w/ period
             $item['size'] = str_replace('fz.', 'fl oz.', $item['size']);
         }
         if (substr($item['size'], 0, 1) == '.') {
             $item['size'] = '0' . $item['size'];
             // add leading zero on decimal qty
         }
         if (strlen(ltrim($item['upc'], '0')) < 5 && $item['scale']) {
             $item['size'] = 'PLU# ' . ltrim($item['upc'], '0');
             // show PLU #s on by-weight
         }
         $pdf->Cell($effective_width, 6, $item['size'], 0, 1, 'C');
         $pdf->SetXY($left + $width * $column, $top + $height * $row + ($height - 42));
         $pdf->SetFont('Gill', '', $this->BIG_FONT);
         $pdf->Cell($effective_width, 12, $price, 0, 1, 'C');
         if ($item['startDate'] != '' && $item['endDate'] != '') {
             // intl would be nice
             $datestr = date('M d', strtotime($item['startDate'])) . chr(0x96) . date('M d', strtotime($item['endDate']));
             $pdf->SetXY($left + $width * $column, $top + $height * $row + ($height - 37));
             $pdf->SetFont('GillBook', '', $this->SMALLEST_FONT);
             $pdf->Cell($effective_width, 20, strtoupper($datestr), 0, 1, 'R');
         }
         if ($item['upc'] != '') {
             $pdf->SetXY($left + $width * $column, $top + $height * $row + ($height - 37));
             $pdf->SetFont('GillBook', '', $this->SMALLEST_FONT);
             $pdf->Cell($effective_width, 20, $item['upc'], 0, 1, 'L');
         }
         $pdf->Image(dirname(__FILE__) . '/' . $this->footer_image, $left - 1 + $width * $column, $top + $height * $row + ($height - $top - 4), $width - 6);
         $count++;
         $sign++;
     }
     $pdf->Output('Signage12UpL.pdf', 'I');
 }
示例#8
0
$db->_DEBUG = 1;
$pdf = new FPDF("L", 'mm', "A4");
$pdf->open();
$pdf->AddPage();
$fonte = 'times';
$pdf->SetLeftMargin(5);
$pdf->SetAutoPageBreak("on", 2);
$pdf->SetFont($fonte, "", 12);
$pdf->sety(15);
$pdf->SetFont($fonte, "b", 12);
$pdf->setx(5);
$pdf->ln();
$pdf->SetFont($fonte, "", 14);
$pdf->setx(5);
$pdf->cell(50, 5, "Controle de Entregas", 0, 1);
$pdf->line(5, $pdf->GetY(), 290, $pdf->GetY());
$pdf->ln(10);
$pdf->setfont($fonte, "B", "14");
$pdf->cell(0, 5, $_GET["dtvenda"], 0, 1, "C");
$pdf->setfillcolor(235);
$pdf->SetFont($fonte, "b", 10);
$total = $db->entregas["total"];
$sql = " SELECT fun_nome,count(*) as total\n         FROM   comandas inner join comandaentrega \n                on cet_comid = com_id\n                inner join funcionarios on fun_id = cet_funid\n         WHERE com_dtcomanda = '" . strformat($_GET["dtvenda"], "dten") . "' group by fun_nome order by fun_nome";
$rs = $db->executa($sql);
$pdf->cell(140, 5, "Funcionário", "B", 0, "C", 1);
$pdf->cell(45, 5, "Qtde", "B", 1, "C", 1);
$pdf->SetFont($fonte, "", 10);
while ($ln = $db->fetch_array($rs)) {
    if ($pdf->getY() >= $pdf->h - 15) {
        $pdf->addpage();
        $pdf->SetFont($fonte, "b", 10);
示例#9
0
 //display date
 $pdf->SetFont('Arial', 'B', 12);
 $pdf->Cell(20, 5, date("Y/m/d"), 0, 1, "C");
 //add new row
 $pdf->Cell(210, 5, '', 0, 1, "C");
 //Explora academy title
 $pdf->SetFont('Helvetica', '', 25);
 $pdf->Cell(200, 15, 'Explora Academy of Design', 0, 1, "C");
 //add new row
 $pdf->Cell(210, 5, '', 0, 1, "C");
 $pdf->SetFont('Arial', '', 12);
 $pdf->SetTextColor(0, 0, 0);
 //nata and all 3 courses
 $pdf->Cell(80, 5, '', 0, 0, "C");
 if (strtoupper($course) == "NATA") {
     $pdf->Cell(10, 5, $pdf->Image($image12, $pdf->GetX(), $pdf->GetY(), 10, 5), 1, 0, 'L', false);
     $pdf->Cell(15, 5, 'NATA', 0, 1, "C");
 } else {
     $pdf->Cell(10, 5, '', 1, 0, "C");
     $pdf->Cell(15, 5, 'NATA', 0, 1, "C");
 }
 $pdf->Cell(1, 1, '', 0, 1, "C");
 $pdf->Cell(210, 4, '', 0, 1, "C");
 $pdf->SetFont('Arial', '', 12);
 $pdf->SetTextColor(0, 0, 0);
 $pdf->Cell(80, 0, '', 0, 0, "C");
 if (strtoupper($course) == "INTERIOR DESIGN") {
     $pdf->Cell(10, 5, $pdf->Image($image12, $pdf->GetX(), $pdf->GetY(), 10, 5), 1, 0, 'L', false);
     $pdf->Cell(41, 5, 'INTERIOR DESIGN', 0, 1, "C");
 } else {
     $pdf->Cell(10, 5, '', 1, 0, "C");
		$pdf->Cell(90,5, ($gepiSchoolAdress2),0,2,'');

	}

	$gepiSchoolZipCode = getSettingValue('gepiSchoolZipCode');
	$gepiSchoolCity = getSettingValue('gepiSchoolCity');
	$pdf->Cell(90,5, ($gepiSchoolZipCode." ".$gepiSchoolCity),0,2,'');
	$gepiSchoolTel = getSettingValue('gepiSchoolTel');
	$gepiSchoolFax = getSettingValue('gepiSchoolFax');

	$passealaligne = '0';
	// entête téléphone
			// emplacement du cadre télécome
			$x_telecom = $pdf->GetX();
			$y_telecom = $pdf->GetY();

	if( $entente_tel==='1' )
	{

		$grandeur = '';
		$text_tel = '';

		if ( $tel_image != '' )
		{

			$a = $pdf->GetX();
			$b = $pdf->GetY();
			$ima = '../../images/imabulle/'.$tel_image.'.jpg';
			$valeurima=redimensionne_image($ima, 15, 15);
			$pdf->Image($ima, $a, $b, $valeurima[0], $valeurima[1]);
示例#11
0
         the others to the right of this one.  Maybe make the comment cell full
         width. **/
     $pdf->Cell($catw, $sh, $grade['category_name'], 0, 0, 'L', 1);
     $pdf->Cell($scorew, $sh, $grade['score'] . "/" . $grade['max_score'], 0, 0, 'C', 1);
     $pdf->Cell($weightw, $sh, $grade['assignment_weight'], 0, 0, 'C', 1);
     $pdf->Cell($avgw, $sh, $grade['avg'], 0, 1, 'C', 1);
     if ($assignInfo['comment'] != '') {
         $pdf->SetFont('Times', 'I', 8);
         $pdf->Cell($datew, $sh, '', 0, 0, 'L', 1);
         $lines = $pdf->GetStringWidth($grade['comment']) / ($pw - $datew);
         $h = $lines * $sh;
         $pdf->MultiCell($pw - $datew, $sh, $grade['comment'], 0, 'L', 1);
         $pdf->SetFont('Times', '', 8);
     }
     /** $x_coord = $pdf->GetX();**/
     $y_coord = $pdf->GetY();
     $rcv++;
 }
 /* determine if custom score chart will fit on current page */
 if ($y_coord + $sh * count($custom_scores) > 10) {
     $pdf->AddPage();
     $pdf->SetTextColor(51, 102, 102);
     $pdf->SetFont('Times', 'B', $titlefs);
     $pdf->SetXY($lm, $tm);
     $pdf->Cell($headingw, $titleh, 'Questar III Student Progress Report (Contd.)', 0, 1, 'C', 0);
     $y_coord = $tm + $titleh;
 }
 $pdf->SetXY($x_coord, $y_coord);
 $pdf->SetFillColor(255, 255, 255);
 $pdf->SetTextColor(0, 0, 0);
 $pdf->SetFont('Times', '', 8);
示例#12
0
 $pdf->AddPage();
 $pdf->setleftmargin(10);
 $pdf->setX(20);
 $pdf->setY(10);
 $pdf->SetFillColor(0, 0, 0);
 $pdf->Cell(190, 140, '', 1, 0, "C");
 $pdf->setX(20);
 $pdf->setY(15);
 $pdf->SetFillColor(0, 0, 0);
 $image1 = 'logo.png';
 // Add some text
 $pdf->SetFont('Arial', '', 20);
 // width, height, text, no border, next line - below & left margin, alignement
 // shree rang in centre
 $pdf->Cell(175, 10, '           Explora Academy of Design', 0, 0, "C");
 $pdf->Cell(15, 10, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 10), 0, 1, 'R', false);
 $pdf->SetFillColor(0, 0, 0);
 $pdf->Rect(20, 26, 175, 1, 'F');
 $pdf->Cell(10, 8, '', 0, 1, "C");
 //set font and height
 $pdf->SetFont('Arial', '', 12);
 $pdf->SetTextColor(0, 0, 0);
 //space before form no.
 $pdf->Cell(20, 10, '', 0, 0, "C");
 $pdf->Cell(20, 7, 'RECEIPT NUMBER:', 0, 0, "C");
 //space between rect and form no tag
 $pdf->Cell(15, 10, '', 0, 0, "C");
 // create box for form
 $pdf->Cell(30, 7, $form, 1, 0, "C");
 //space after box
 $pdf->Cell(30, 10, '', 0, 0, "C");
示例#13
0
 public function drawPDF()
 {
     $pdf = new \FPDF('P', 'mm', 'Letter');
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
         $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     }
     $width = 52;
     // tag width in mm
     $height = 31;
     // tag height in mm
     $left = 6;
     // left margin
     $top = 16;
     // top margin
     $pdf->SetTopMargin($top);
     //Set top margin of the page
     $pdf->SetLeftMargin($left);
     //Set left margin of the page
     $pdf->SetRightMargin($left);
     //Set the right margin of the page
     $pdf->SetAutoPageBreak(False);
     // manage page breaks yourself
     $data = $this->loadItems();
     $num = 0;
     // count tags
     $x = $left;
     $y = $top;
     foreach ($data as $item) {
         // extract & format data
         $price = $item['normal_price'];
         $desc = strtoupper(substr($item['posDescription'], 0, 25));
         $brand = ucwords(strtolower(substr($item['brand'], 0, 13)));
         $pak = $item['units'];
         $size = $item['units'] . "-" . $item['size'];
         $sku = $item['sku'];
         $ppu = $item['pricePerUnit'];
         $vendor = substr($item['vendor'], 0, 7);
         $upc = $item['upc'];
         if ($num % 32 == 0) {
             $pdf->AddPage();
             $x = $left;
             $y = $top;
         } else {
             if ($num % 4 == 0) {
                 $x = $left;
                 $y += $height;
             }
         }
         $pdf->SetFont($this->font, '', 8);
         $pdf->SetXY($x, $y);
         // try normal wordwrap
         // but squeeze into two lines if needed
         $wrapped = wordwrap($desc, 12, "\n", true);
         if (count(explode("\n", $wrapped)) > 2) {
             $wrapped = substr($desc, 0, 12);
             if ($wrapped[11] != ' ') {
                 $wrapped .= '-';
             }
             $wrapped .= "\n";
             $wrapped .= trim(substr($desc, 12));
         }
         $pdf->MultiCell($width / 2, 3, $wrapped, 0, 'L');
         $pdf->SetX($x);
         $pdf->Cell($width / 2, 3, date('n/j/y ') . $size, 0, 1, 'L');
         $pdf->SetFont($this->font, 'B', 18);
         //change font for price
         $pdf->SetX($x);
         $pdf->Cell($width / 2, 8, $price, 0, 1, 'L');
         $args = array('height' => 7, 'align' => 'L', 'fontsize' => 8, 'width' => 0.23, 'font' => $this->font);
         $b_y = $pdf->GetY();
         $pdf = $this->drawBarcode($upc, $pdf, $x, $b_y, $args);
         // move right by tag width
         $x += $width;
         $num++;
     }
     $pdf->Output('Tags4x8P.pdf', 'I');
 }
示例#14
0
function parse_pdf_content($content, $member_id)
{
    // parse text content from Smarty to pdf content
    global $db, $config, $t;
    $pdf_content = '';
    $margins = array(mm_to_pt(20), mm_to_pt(20), mm_to_pt(20), mm_to_pt(20));
    //left, top, right, bottom (in points) 56pt ~= 20mm
    $font_size = 14;
    //points
    $pdf = new FPDF('P', 'pt', 'A4');
    // portrait, A4
    $pdf->SetCompression(false);
    $pdf->SetMargins($margins[0], $margins[1], $margins[2]);
    //only left, top, right margins. bottom margin equals to 20mm by default.
    $pdf->SetTitle('Your Invoice');
    $pdf->SetSubject('*** Your Payment');
    $pdf->SetAuthor('aMember');
    $pdf->AddPage();
    $pdf->SetFont('Arial', '', $font_size);
    $current_x = $pdf->GetX();
    $current_y = $pdf->GetY();
    $width = mm_to_pt(210);
    $height = mm_to_pt(270);
    $width = $width - $margins[0] - $margins[2];
    // target width
    $height = $height - $margins[1] - $margins[3];
    // target height
    $image = $config['root_dir'] . "/logo.jpg";
    // logo path to include in pdf at top-right corner
    if (is_file($image)) {
        $size = getimagesize($image);
        $x = $width - $size[0] + $margins[0];
        $y = $current_y;
        $pdf->Image($image, $x, $y, $size[0], $size[1]);
        // use original size
        $current_y += $size[1];
    }
    $current_y += $font_size;
    //pt
    $contacts = explode("\n", $config['invoice_contacts']);
    // output contact information right-aligned
    $max_length = 0;
    foreach ($contacts as $row) {
        $row = trim($row);
        $length = $pdf->GetStringWidth($row);
        if ($length > $max_length) {
            $max_length = $length;
        }
    }
    $x = $width - $max_length + $margins[0];
    $y = $current_y;
    foreach ($contacts as $row) {
        $row = trim($row);
        $attr = get_font_styles($row);
        $pdf->SetFont('Arial', $attr, $font_size);
        $pdf->Text($x, $y, strip_tags($row));
        $y += $font_size;
    }
    $current_y = $y;
    $pdf->SetFont('Arial', '', $font_size);
    //return font settings
    // customer contacts
    $u = $db->get_user($member_id);
    if (!$t) {
        $t =& new_smarty();
    }
    $t->assign('u', $u);
    $cust_contacts = $t->fetch('mail_receipt_contact.pdf.txt');
    $cust_contacts = explode("\n", $cust_contacts);
    // output contact information left-aligned
    $num_rows = count($contacts);
    $x = $margins[0];
    $y = $current_y - $font_size * $num_rows;
    // $num_rows rows up from contact information and output customer data
    foreach ($cust_contacts as $row) {
        $row = trim($row);
        $attr = get_font_styles($row);
        $pdf->SetFont('Arial', $attr, $font_size);
        $pdf->Text($x, $y, strip_tags($row));
        $y += $font_size;
    }
    $current_y = $y;
    /*
    $y = $current_y - $font_size * 4; // 4 rows up from contact information and output customer data
    
    $string = $u['name_f'] . ' ' . $u['name_l'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    $string = $u['street'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    $string = $u['zip'] . ' ' . $u['city'];
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    
    	$state = db_getStateByCode($u['country'], $u['state']);
    	$country = db_getCountryByCode($u['country']);
    $string = $state .  ' '  . $country;
    $pdf->Text ($x, $y, $string);
    $y += $font_size;
    */
    $current_y = $y + $font_size * 2;
    //2 rows down
    $pdf->SetFont('Arial', '', $font_size);
    //return font settings
    // remove new lines
    $content = str_replace("\n", "", $content);
    $content = str_replace("\r", "", $content);
    $content = str_replace("&pound;", chr(163), $content);
    // split text by <br />
    $content = explode("<br />", $content);
    $y = $current_y;
    // count maximum columns widths
    $widths = array();
    foreach ($content as $text) {
        $text = trim($text);
        if (preg_match('/\\|/i', $text, $regs)) {
            $column = 0;
            $items = explode("|", $text);
            foreach ($items as $item) {
                $length = $pdf->GetStringWidth(trim(strip_tags($item))) + 10;
                if ($widths[$column] < $length) {
                    $widths[$column] = $length;
                }
                $column++;
            }
        }
    }
    $length = 0;
    for ($i = 1; $i < count($widths); $i++) {
        $length += $widths[$i];
    }
    // width of column 0 is *
    $widths[0] = $width - $length;
    foreach ($content as $hr_content) {
        $hr_content = trim($hr_content);
        // split text by <hr>
        $hr_content = explode("<hr>", $hr_content);
        $hr_count = count($hr_content) - 1;
        //<br /> add new line
        if ($hr_count < 1 && strip_tags($hr_content[0]) == '') {
            $y += $font_size;
        }
        foreach ($hr_content as $text) {
            $line_feeds = 1;
            // how much rows feed
            if (strip_tags($text) != '') {
                // if there is a text
                if (!preg_match('/\\|/i', $text, $regs)) {
                    // simple text
                    $y += $font_size * $line_feeds;
                    $attr = get_font_styles($text);
                    $text = trim(strip_tags($text));
                    $pdf->SetFont('Arial', $attr, $font_size);
                    $pdf->Text($x, $y, $text);
                    // simple textout. no line feeds allowed.
                    /*
                    $length = $pdf->GetStringWidth ($text);
                    while ($length > $width)
                        $line_feeds++;
                    */
                } else {
                    //table content (splitted by "|")
                    $border = 0;
                    $fill = 0;
                    $pdf->SetFillColor(192, 192, 192);
                    // Silver
                    if (preg_match('/<fill>(.*)<\\/fill>/i', $text, $regs)) {
                        $text = $regs[1];
                        $fill = 1;
                    }
                    $text = strip_tags($text);
                    $items = explode("|", $text);
                    $column = 0;
                    $x = $margins[0];
                    foreach ($items as $item) {
                        $attr = get_font_styles($item);
                        $item = trim(strip_tags($item));
                        $pdf->SetFont('Arial', $attr, $font_size);
                        if ($column > 0) {
                            $align = 'R';
                        } else {
                            $align = 'L';
                        }
                        $pdf->SetXY($x, $y);
                        $pdf->MultiCell($widths[$column], $font_size, $item, $border, $align, $fill);
                        // multi rows output
                        for ($i = 1; $i < $line_feeds; $i++) {
                            $_y = $y + $i * $font_size;
                            $pdf->SetXY($x, $_y);
                            $pdf->MultiCell($widths[$column], $font_size, '', $border, $align, $fill);
                            // empty rows
                        }
                        if ($column == 0) {
                            // count line feeds only for 0 column
                            $length = $pdf->GetStringWidth($item);
                            while ($length > $widths[$column]) {
                                $line_feeds++;
                                $length -= $widths[$column];
                            }
                        }
                        $x += $widths[$column];
                        $column++;
                    }
                    $y += $font_size * $line_feeds;
                    $pdf->SetXY($margins[0], $y);
                }
            }
            // (strip_tags($text) != '')
            if ($hr_count > 0) {
                // check count of <hr> (do not draw last <hr>)
                $y += 2;
                $pdf->Line($margins[0], $y, $margins[0] + $width, $y);
                $y += 2;
                $hr_count--;
            }
            $x = $margins[0];
        }
        //foreach hr_content
    }
    //foreach content
    $current_y = $y;
    $pdf_content = $pdf->Output('', 'S');
    //get pdf content
    return $pdf_content;
}
示例#15
0
 function __construct($lineItems, $lineItemTotals, $filename, $save = false)
 {
     App::import('vendor', 'fpdf/fpdf');
     $orientation = 'P';
     $unit = 'pt';
     $format = 'A4';
     $margin = 40;
     $pdf = new FPDF($orientation, $unit, $format);
     App::import('Helper', 'Time');
     $timeHelper = new TimeHelper();
     setlocale(LC_MONETARY, 'th_TH');
     $pdf->AddPage();
     $pdf->SetTopMargin($margin);
     $pdf->SetLeftMargin($margin);
     $pdf->SetRightMargin($margin);
     $pdf->SetAutoPageBreak(true, $margin);
     $pdf->SetY($pdf->GetY() + 60);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(0);
     $pdf->SetFillColor(255);
     $pdf->SetLineWidth(1);
     $pdf->SetFont('Arial', 'B', '10');
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 30;
     $pdf->MultiCell($cell_width, 25, "No.\n ", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $pdf->Cell(250, 25, "Description", 'LTR', 0, 'C');
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 48;
     $pdf->MultiCell($cell_width, 25, "# Ordered", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 48;
     $pdf->MultiCell($cell_width, 25, "# Supplied", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 70;
     $pdf->MultiCell($cell_width, 25, "Amount Wholesale", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 70;
     $pdf->MultiCell($cell_width, 25, "Amount Retail", 'LTR', 'C');
     $pdf->SetY($pdf->GetY() - 25);
     $pdf->SetFont('Arial', '');
     $pdf->SetFillColor(238);
     $pdf->SetLineWidth(0.2);
     $pdf->SetY($pdf->GetY() + 25);
     $num = 1;
     $number_ordered = 0;
     $number_supplied = 0;
     foreach ($lineItems as $lineItem) {
         $pdf->Cell(30, 20, $num++, 1, 0, 'L');
         $pdf->Cell(250, 20, $lineItem['Product']['short_description'], 1, 0, 'L');
         $pdf->Cell(48, 20, $lineItem['LineItem']['ordered'], 1, 0, 'R');
         $pdf->Cell(48, 20, $lineItem['LineItem']['supplied'], 1, 0, 'R');
         $pdf->Cell(70, 20, money_format("%i", $lineItem['LineItem']['amount_wholesale']), 1, 0, 'R');
         $pdf->Cell(70, 20, money_format("%i", $lineItem['LineItem']['amount_retail']), 1, 1, 'R');
     }
     $pdf->SetX($pdf->GetX() + 30);
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(250, 20, "TOTALS", 1);
     $pdf->SetFont('Arial', '');
     $pdf->Cell(48, 20, $lineItemTotals['LineItem']['ordered'], 1, 0, 'R');
     $pdf->Cell(48, 20, $lineItemTotals['LineItem']['ordered'], 1, 0, 'R');
     $pdf->Cell(70, 20, money_format("%i", $lineItemTotals['LineItem']['amount_wholesale']), 1, 0, 'R');
     $pdf->Cell(70, 20, money_format("%i", $lineItemTotals['LineItem']['amount_retail']), 1, 1, 'R');
     if ($save) {
         $pdf->Output($filename, 'F');
     } else {
         $pdf->Output($filename, 'I');
     }
 }
示例#16
0
 $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L');
 $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj("Document édité par " . $_SESSION['login2']), 0, 'L');
 $pdf->SetFont('Times', '', 18);
 $pdf->SetFillColor(153, 153, 153);
 $pdf->SetTextColor(0, 0, 0);
 $pdf->SetDrawColor(153, 153, 153);
 $pdf->SetLineWidth(0.3);
 $pdf->SetFont('', 'B');
 $pdf->MultiCell(0, 12, utf8_decode("Planning pour la période :" . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true);
 $pdf->SetFont('Times', '', 11);
 $pdf->Ln();
 // Largeurs des colonnes
 $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7);
 $header = $_POST['liste_jour'];
 $hauteur = 5;
 $x2 = $pdf->GetY();
 // En-tête
 for ($i = 0; $i < count($header); $i++) {
     $pdf->SetXY($w[$i] * $i + 10, $x2);
     $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C');
     if ($header[$i]["valeur"] == date("w", $date_debut)) {
         $case_vide = $i - 1;
     }
 }
 $pdf->Ln();
 $x2 = $pdf->GetY();
 if ($case_vide >= 0) {
     for ($i = 0; $i <= $case_vide; $i++) {
         $pdf->SetXY($w[$i] * $i + 10, $x2);
         $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C');
     }
示例#17
0
文件: sbr.php 项目: amage/fl-ru-damp
 /**
  * Генерирует PDF-документ на основании XML-файла.
  *
  * @param string $file          Файл для обработки
  * @param mixed $replacements   массив для подстановки значений
  * @return FPDF сформированный документ PDF или FALSE в случае неудачи
  */
 public static function xml2pdf($file, $replacements = false)
 {
     // Новая обработка PDF
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/odt2pdf.php';
     $tpl = basename($file, ".xml") . ".odt";
     $t = new odt2pdf($tpl);
     $t->convert($replacements);
     return $t;
     /**
      * @deprecated
      */
     if (!file_exists($file)) {
         return false;
     }
     require_once dirname(__FILE__) . '/fpdf/fpdf.php';
     define('FPDF_FONTPATH', dirname(__FILE__) . '/fpdf/font/');
     if (is_array($replacements)) {
         foreach ($replacements as &$val) {
             $val = htmlspecialchars_decode($val, ENT_QUOTES);
         }
     }
     $replacements['$tab'] = '    ';
     $xml = new DOMDocument('1.0', 'windows-1251');
     $xml->load($file);
     $pdf = new FPDF();
     // Загружаем шрифты
     $pdf->AddFont('ArialMT', '', 'c9bb7ceca00657d007d343f4e34b71a8_arial.php');
     $pdf->AddFont('Arial-BoldMT', '', '9cb9fc616ba50d7ecc7b816984f2ffda_arialbd.php');
     $pdf->AddFont('TimesNewRomanPSMT', '', '5f37f1915715e014ee2254b95c0b6cab_times.php');
     $pdf->AddFont('TimesNewRomanPS-BoldMT', '', 'e07f6c05a47ebec50a80f29789c7f1f6_timesbd.php');
     /*
             Загружаем XML-документ и читаем из него основные параметры лоя итогового PDF-документа
     */
     $root = $xml->documentElement;
     $title = $root->getAttribute('title') ? iconv('windows-1251', 'utf-8', $root->getAttribute('title')) : '';
     // заголовок документа
     $author = $root->getAttribute('author');
     // автор
     $margin_left = $root->getAttribute('margin-left') ? $root->getAttribute('margin-left') : 20;
     // отступ слева
     $margin_right = $root->getAttribute('margin-right') ? $root->getAttribute('margin-right') : 20;
     // отступ справа
     $margin_top = $root->getAttribute('margin-top') ? $root->getAttribute('margin-top') : 20;
     // отступ сверху
     $font_name = $root->getAttribute('font-name') ? $root->getAttribute('font-name') : 'ArialMT';
     // дефолтный шрифт (имя)
     $font_size = (int) $root->getAttribute('font-size') ? (int) $root->getAttribute('font-size') : 10;
     // дефолтный шрифт (размер)
     $text_width = (int) $root->getAttribute('width') ? (int) $root->getAttribute('width') : 170;
     // ширина печатной области документа
     $paragraph_indent = (int) $root->getAttribute('paragraph-indent') ? (int) $root->getAttribute('paragraph-indent') : 0;
     // отступ между параграфами
     $printable = $pdf->h - $margin_top - 20;
     $pdf->SetTitle($title, true);
     $pdf->SetAuthor($author);
     $pdf->SetLeftMargin($margin_left);
     $pdf->SetRightMargin($margin_right);
     $pdf->SetTopMargin($margin_top);
     $pdf->AddPage();
     $pdf->SetFont($font_name, '', $font_size);
     $pdf->SetX($margin_left);
     $locates = array();
     // разбор XML-документа
     $xpath = new DOMXPath($xml);
     $scale = $xpath->query('/document/page/*');
     if ($scale->length) {
         $footer = $xpath->query('//footer');
         $footer = $footer->length ? $footer->item(0) : NULL;
         $no_brake = $xpath->query('//nobreak');
         $no_brake = $no_brake->length ? TRUE : FALSE;
         // если есть теги <nobreak>, то расставляем разрывы страниц руками
         if ($no_brake) {
             $pdf->SetAutoPageBreak(false);
         }
         $last_y = 0;
         $pages = array();
         foreach ($scale as $node) {
             $last_y = intval($pdf->y);
             if ($node->tagName == 'nobreak' && $node->getAttribute('start')) {
                 $max_h = $last_y;
                 $loc_offset = 0;
                 foreach ($xpath->query('//cell|locate[(following::nobreak)]') as $i => $nd) {
                     if ($nd->tagName == 'nobreak' && $node->getAttribute('end')) {
                         break;
                     }
                     $_h = $nd->getAttribute('height');
                     if ($i > 0 && !$loc_offset) {
                         $_h = 0;
                     }
                     $max_h += intval($_h);
                     $loc_offset = $nd->getAttribute('x_offset');
                 }
                 $max_h += $last_y;
                 if ($max_h > $printable) {
                     if ($footer) {
                         $pdf->SetY(-20);
                         $pdf->SetFont($font_name, '', 9);
                         $pdf->Cell(0, 10, self::prepareNodeText($footer), 0, 0, 'C');
                         $pages[] = $pdf->PageNo();
                     }
                     $pdf->AddPage();
                 }
             }
             if ($no_brake && $pdf->y > $printable) {
                 if ($footer && !in_array($pdf->PageNo(), $pages)) {
                     $pdf->SetY(-20);
                     $pdf->SetFont($font_name, '', 9);
                     $pdf->Cell(0, 10, self::prepareNodeText($footer), 0, 0, 'C');
                     $pages[] = $pdf->PageNo();
                 }
                 $pdf->AddPage();
             }
             if (!(int) $node->getAttribute('keep-pos')) {
                 $pdf->SetX($margin_left);
             }
             // сброс позиции по X-оси если <node keep-pos="0" или не задан
             if ((int) $node->getAttribute('offset-left')) {
                 $pdf->SetX((int) $node->getAttribute('offset-left') + $margin_left);
             }
             if ($node->tagName == 'text') {
                 // вывод строки
                 if ($node->getAttribute('font-name')) {
                     $font_name = $node->getAttribute('font-name');
                 }
                 if ((int) $node->getAttribute('font-size')) {
                     $font_size = (int) $node->getAttribute('font-size');
                 }
                 $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'C';
                 $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width;
                 $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5;
                 $border = $node->getAttribute('border') ? strtoupper($node->getAttribute('border')) : 0;
                 $text = self::prepareNodeText($node, $replacements);
                 if (!($color = $node->getAttribute('color'))) {
                     $color = '000000';
                 }
                 $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
                 $pdf->SetFont($font_name, '', $font_size);
                 $skip_empty = (int) $node->getAttribute('skip-empty') ? (int) $node->getAttribute('skip-empty') : 0;
                 if ((int) $skip_empty) {
                     if (!trim($text)) {
                         continue;
                     }
                 }
                 $pdf->Cell($width, $height, trim($text), $border, 1, $align);
             } elseif ($node->tagName == 'paragraph') {
                 // выводит многострочный текстовый блок, можно указывать тип выравнивания текста (L, J, R, C)
                 if (($show_if = $node->getAttribute('show-if')) && !$replacements[$show_if]) {
                     continue;
                 }
                 if ($node->getAttribute('font-name')) {
                     $font_name = $node->getAttribute('font-name');
                 }
                 if ((int) $node->getAttribute('font-size')) {
                     $font_size = (int) $node->getAttribute('font-size');
                 }
                 $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'J';
                 $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width;
                 $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5;
                 $border = $node->getAttribute('border') ? strtoupper($node->getAttribute('border')) : 0;
                 $keep_text_wrap = (int) $node->getAttribute('keep-text-wrap') ? (int) $node->getAttribute('keep-text-wrap') : 0;
                 $text = self::prepareNodeText($node, $replacements, $keep_text_wrap);
                 if (!($color = $node->getAttribute('color'))) {
                     $color = '000000';
                 }
                 $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
                 $pdf->SetFont($font_name, '', $font_size);
                 $skip_empty = (int) $node->getAttribute('skip-empty') ? (int) $node->getAttribute('skip-empty') : 0;
                 if ((int) $skip_empty) {
                     if (!trim($text)) {
                         continue;
                     }
                 }
                 $pdf->MultiCell($width, $height, $text, $border, $align);
                 if ($paragraph_indent) {
                     $pdf->Ln($paragraph_indent);
                 }
             } elseif ($node->tagName == 'ln') {
                 // перевод строки
                 $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5;
                 $pdf->Ln($height);
             } elseif ($node->tagName == 'cell') {
                 // рисует ячейку
                 if ($node->getAttribute('font-name')) {
                     $font_name = $node->getAttribute('font-name');
                 }
                 if ((int) $node->getAttribute('font-size')) {
                     $font_size = (int) $node->getAttribute('font-size');
                 }
                 $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'J';
                 $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width;
                 $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5;
                 $border = $node->getAttribute('border') != '' ? (int) $node->getAttribute('border') : 1;
                 $keep_text_wrap = (int) $node->getAttribute('keep-text-wrap') ? (int) $node->getAttribute('keep-text-wrap') : 0;
                 $text = self::prepareNodeText($node, $replacements, $keep_text_wrap);
                 if (!($color = $node->getAttribute('color'))) {
                     $color = '000000';
                 }
                 $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
                 $pdf->SetFont($font_name, '', $font_size);
                 $pdf->Cell($width, $height, $text, $border, 0, $align);
             } elseif ($node->tagName == 'locate') {
                 // перемещает указатель в определенную позицию в документе
                 $x = $node->getAttribute('x') ? $node->getAttribute('x') : 0;
                 $y = $node->getAttribute('y') ? $node->getAttribute('y') : 0;
                 $x_offset = (int) $node->getAttribute('x_offset') ? (int) $node->getAttribute('x_offset') : 0;
                 $y_offset = (int) $node->getAttribute('y_offset') ? (int) $node->getAttribute('y_offset') : 0;
                 if (strpos($x, '@') !== false) {
                     $x = $locates['x'][$x] + $x_offset;
                 }
                 if (strpos($y, '@') !== false) {
                     $y = $locates['y'][$y] + $y_offset;
                 }
                 if (!$x) {
                     $x = $pdf->GetX() + $x_offset;
                 }
                 if (!$y) {
                     $y = $pdf->GetY() + $y_offset;
                 }
                 $pdf->SetXY($x, $y);
             } elseif ($node->tagName == 'fix-locate') {
                 // перемещает указатель в определенную позицию в документе
                 if ($x = $node->getAttribute('x')) {
                     $locates['x'][$x] = $pdf->GetX();
                 }
                 if ($y = $node->getAttribute('y')) {
                     $locates['y'][$y] = $pdf->GetY();
                 }
             } elseif ($node->tagName == 'line') {
                 // рисует простую горизонтальную линию
                 $x = (int) $node->getAttribute('x') ? (int) $node->getAttribute('x') : $margin_left;
                 $y = (int) $node->getAttribute('y') ? (int) $node->getAttribute('y') : $margin_top;
                 $len = (int) $node->getAttribute('len') ? (int) $node->getAttribute('len') : $text_width;
                 if ($x) {
                     $pdf->setX($x);
                 }
                 if ($y) {
                     $pdf->setY($y);
                 }
                 $pdf->Cell($len, 0, '', 1);
             } elseif ($node->tagName == 'newpage') {
                 //новая страница и перевод указателя на нее
                 $pdf->AddPage();
             }
         }
     }
     return $pdf;
 }
示例#18
0
<?php

require 'fpdf/fpdf.php';
$pdf = new FPDF('P', 'cm', 'A4');
//Titres des colonnes
$header = array('Nom', 'Prenom', 'Adresse e-mail', 'Téléphone', 'Fax', 'Status cotisation');
$pdf->SetFont('Arial', 'B', 14);
$pdf->AddPage();
$pdf->SetFillColor(96, 96, 96);
$pdf->SetTextColor(255, 255, 255);
mysql_connect('localhost', 'root', 'monpass') or die("ERROR DATABASE CONNECTION");
mysql_select_db('compfundation') or die("DATA SELECTION ERRROR");
$query = "select * from intervenants";
$resultat = mysql_query($query);
$pdf->SetXY(3, 3);
for ($i = 0; $i < sizeof($header); $i++) {
    $pdf->cell(5, 1, $header[$i], 1, 0, 'C', 1);
}
$pdf->SetFillColor(0xdd, 0xdd, 0xdd);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Arial', '', 10);
$pdf->SetXY(3, $pdf->GetY() + 1);
$fond = 0;
while ($row = mysql_fetch_array($resultat)) {
    $pdf->cell(5, 0.7, $row['int_nom'], 1, 0, 'C', $fond);
    $pdf->cell(5, 0.7, $row['int_prenom'], 1, 0, 'C', $fond);
    $pdf->cell(5, 0.7, $row['int_email'], 1, 0, 'C', $fond);
    $pdf->SetXY(3, $pdf->GetY() + 0.7);
    $fond = !$fond;
}
$pdf->output();
    if ($status == "No Requirements") {
        $status = "Cleared";
    }
    $listOfSignatories["status"][$key] = $status;
}
//var_dump($listOfSignatories);
$fpdf = new FPDF('P', 'mm', 'Legal');
$fpdf->SetDisplayMode('fullpage', 'continuous');
$fpdf->SetTitle("SOCS Clearance - Export Copy");
$fpdf->SetCreator("USEP SOCS");
$fpdf->SetAuthor("University of Southeastern Philippines");
$fpdf->SetSubject("Electronic Clearance (export copy)");
$fpdf->SetMargins(15, 15, 15);
$fpdf->AddPage();
$fpdf->SetY('15');
$fpdf->Image('logo.jpg', 13, $fpdf->GetY() - 5, 25);
printBody();
$fpdf->Cell(0, 0, "Registrar's Copy", 0, 1, 'R', false);
$fpdf->Ln(4);
$fpdf->Cell(0, 0, "", 1, 1, 'L', true);
$fpdf->Ln(4);
$fpdf->Cell(0, 0, "Adviser's Copy", 0, 1, 'R', false);
$fpdf->SetY($fpdf->GetY() + 10);
$fpdf->Image('logo.jpg', 13, $fpdf->GetY() - 5, 25);
printBody();
function printBody()
{
    global $fpdf, $stud_id, $stud_gender, $stud_name, $stud_year, $stud_course, $stud_dept, $current_sem, $current_sy, $listOfSignatories, $signatory_model;
    $fontsize = 10;
    $single_spacing = 4;
    $double_spacing = 8;
$owner_id = $getd[0];
$business_id = $getd[1];
$stat = $getd[2];
$linebus = mysql_query("select * from tempbusnature where owner_id={$owner_id} and\r\n\t\t\tbusiness_id={$business_id} and active=1") or die(mysql_error());
$number_of_rows = mysql_numrows($linebus);
$i = 1;
//$pdf->SetY($Y_Table_Position);
while ($busline = mysql_fetch_row($linebus)) {
    $pdf->SetX(5);
    $pdf->Cell(120, 5, $busline[2], 1, 0, 'L');
    $pdf->SetX(125);
    $pdf->Cell(40, 5, $busline[3], 1, 0, 'R');
    $pdf->SetX(165);
    $pdf->Cell(40, 5, $busline[4], 1, 0, 'R');
    $i++;
    $pdf->SetY($pdf->GetY() + 5);
}
$pdf->Cell(200, 5, '', 0, 2, 'C');
$pdf->SetX(5);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(120, 5, 'TAXES AND FEES:', 1, 0, 'L');
$pdf->Cell(40, 5, 'PERIOD COVERED:', 1, 0, 'C');
$pdf->Cell(40, 5, 'AMOUNT:', 1, 1, 'C');
$gettax = mysql_query("select a.compval, b.tfodesc, c.payment_part, c.ts\r\n\t\t\t\t\t from tempassess a, ebpls_buss_tfo b, ebpls_transaction_payment_or_details c\r\n\t\t\t\t\t where a.tfoid = b.tfoid and a.owner_id = {$owner_id} and a.business_id={$business_id}\r\n\t\t\t\t\t and a.owner_id=c.trans_id and a.business_id=c.payment_id and a.transaction=c.transaction\r\n\t\t\t\t\t and a.active=1");
$i = 1;
//$pdf->SetY($Y_Table_Position);
while ($busline = mysql_fetch_row($gettax)) {
    $periodico = $busline[2];
    //dito ka maglagay ng code kung gagawin mong descriptive un payment mode, ok!?!?!?!
    if ($paymentmode == 'annual') {
        $paymentmode = 'One Year';
    $pdf->Cell(35, 4, $arrData[name], $border);
    $pdf->Ln();
    $pdf->Cell(16, 4, "From", $border);
    $pdf->Cell(35, 4, $from, $border);
    $pdf->Ln();
    $pdf->Cell(16, 4, "Subject", $border);
    $pdf->Cell(35, 4, $arrData[subject], $border);
    $pdf->Ln();
    $pdf->Cell(16, 4, "College", $border);
    $pdf->Cell(35, 4, $arrData[college], $border);
    $pdf->Ln();
    $pdf->Ln();
    if ($arrData[picture] != "" && file_exists("residentsnh/" . $arrData[picture])) {
        $path_parts = pathinfo($arrData[picture]);
        if ($path_parts[extension] != 'bmp') {
            $pdf->Image("residentsnh/" . $arrData[picture], $pdf->GetX() + 100, $pdf->GetY() - 25, 18);
        } else {
            echo "Error, " . $arrData[name] . " " . $arrData[surname] . " has it's picture in BMP format!<br>";
        }
    } else {
        $pdf->Image("imgs/no_picture.png", $pdf->GetX() + 100, $pdf->GetY() - 25, 18);
    }
    $pdf->Line(46, $pdf->GetY(), 163, $pdf->GetY());
    $pdf->Ln();
    $pdf->Ln();
    if ($i == 8) {
        $pdf->AddPage();
        $i = 0;
    }
}
$pdf->Output();
示例#22
0
 function __construct($products, $order, $filename, $save = false)
 {
     App::import('vendor', 'fpdf/fpdf');
     $orientation = 'P';
     $unit = 'pt';
     $format = 'A4';
     $margin = 40;
     $pdf = new FPDF($orientation, $unit, $format);
     App::import('Helper', 'Time');
     $timeHelper = new TimeHelper();
     setlocale(LC_MONETARY, 'th_TH');
     $pdf->AddPage();
     $pdf->SetTopMargin($margin);
     $pdf->SetLeftMargin($margin);
     $pdf->SetRightMargin($margin);
     $pdf->SetAutoPageBreak(true, $margin);
     $pdf->SetY($pdf->GetY() + 60);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(0);
     $pdf->SetFillColor(255);
     $pdf->SetLineWidth(1);
     $pdf->Cell(50, 25, "Order ID: ", 'LT', 0, 'L');
     $pdf->SetFont('Arial', '');
     $pdf->Cell(50, 25, $order['Order']['id'], 'T', 0, 'L');
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(100, 25, 'Customer Name: ', 'T', 0, 'L');
     $pdf->SetFont('Arial', '');
     $pdf->Cell(316, 25, $order['User']['name'], 'TR', 1, 'L');
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(100, 25, "Delivery Date: ", 'LT', 0, 'L');
     $pdf->SetFont('Arial', '');
     $pdf->Cell(416, 25, $timeHelper->format($format = 'd-m-Y', $order['Delivery']['date']), 'TR', 1, 'L');
     $pdf->SetFont('Arial', 'B', '10');
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 30;
     $pdf->MultiCell($cell_width, 25, "No.\n ", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $pdf->Cell(250, 25, "Description", 'LTR', 0, 'C');
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 48;
     $pdf->MultiCell($cell_width, 25, "Number Ordered", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 48;
     $pdf->MultiCell($cell_width, 25, "Number Supplied", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 70;
     $pdf->MultiCell($cell_width, 25, "Amount per Unit", 'LTR', 'C');
     $pdf->SetXY($current_x + $cell_width, $current_y);
     $current_y = $pdf->GetY();
     $current_x = $pdf->GetX();
     $cell_width = 70;
     $pdf->MultiCell($cell_width, 25, "Amount\n ", 'LTR', 'C');
     $pdf->SetY($pdf->GetY() - 25);
     $pdf->SetFont('Arial', '');
     $pdf->SetFillColor(238);
     $pdf->SetLineWidth(0.2);
     $pdf->SetY($pdf->GetY() + 25);
     $num = 1;
     $number_ordered = 0;
     $number_supplied = 0;
     foreach ($products as $product) {
         $pdf->Cell(30, 20, $num++, 1, 0, 'L');
         $pdf->Cell(250, 20, $product['Product']['short_description'], 1, 0, 'L');
         $pdf->Cell(48, 20, $product['LineItem']['quantity'], 1, 0, 'R');
         $number_ordered += $product['LineItem']['quantity'];
         $pdf->Cell(48, 20, $product['LineItem']['quantity_supplied'], 1, 0, 'R');
         $number_supplied += $product['LineItem']['quantity_supplied'];
         $pdf->Cell(70, 20, money_format("%i", $product['Product']['selling_price']), 1, 0, 'R');
         $pdf->Cell(70, 20, money_format("%i", $product['LineItem']['total_price_supplied']), 1, 1, 'R');
     }
     $pdf->SetX($pdf->GetX() + 30);
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(250, 20, "TOTALS", 1);
     $pdf->SetFont('Arial', '');
     $pdf->Cell(48, 20, $number_ordered, 1, 0, 'R');
     $pdf->Cell(48, 20, $number_supplied, 1, 0, 'R');
     $pdf->Cell(70, 20, "N.A.", 1, 0, 'R');
     $pdf->Cell(70, 20, money_format("%i", $order['Order']['total_supplied']), 1, 1, 'R');
     $pdf->SetY($pdf->GetY() + 25);
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(80, 20, "Amount Paid: ");
     $pdf->SetFont('Arial', '');
     $pdf->Cell(80, 20, money_format("%i", $order['Order']['total']), 0, 1);
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(80, 20, "Actual Amount: ");
     $pdf->SetFont('Arial', '');
     $pdf->Cell(80, 20, money_format("%i", $order['Order']['total_supplied']), 0, 1);
     $pdf->SetFont('Arial', 'B');
     $pdf->Cell(80, 20, "Rebate Amount: ");
     $pdf->SetFont('Arial', '');
     $pdf->Cell(80, 20, money_format("%i", $order['Order']['total'] - $order['Order']['total_supplied']), 0, 1);
     if ($save) {
         $pdf->Output($filename, 'F');
     } else {
         $pdf->Output($filename, 'I');
     }
 }
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(10, 12, "No. :", "", 0, 'L');
 $pdf->SetFont("Times", "B", 10);
 $pdf->Cell(0, 12, "{$paymentvoucher_prefix}{$paymentvoucher_no}", "", 0, 'R');
 //paymentvoucher Date label block (5)
 $pdf->SetXY($xmargin + 145, 18);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(10, 12, "Date :", "", 0, 'L');
 $pdf->SetFont("times", "B", 10);
 $pdf->Cell(0, 12, "{$paymentvoucher_date}", "", 0, 'R');
 //paymentvoucher From label block (6)
 $pdf->SetXY($xmargin, 30);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(30, 12, "PAID TO :", "", 0, 'L');
 $pdf->SetFont("Times", "B", 12);
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 9, $pdf->GetX() + 155, $pdf->GetY() + 9);
 $pdf->Cell(0, 12, "{$paidto}", "", 0, 'L');
 //paymentvoucher AMT in Text label block (7)
 $pdf->SetXY($xmargin, 38);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell($xmargin + 15, 12, "THE SUM OF :", "", 0, 'L');
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 9, $pdf->GetX() + 155, $pdf->GetY() + 9);
 //$pdf->Line($pdf->GetX(),86,$pdf->GetX()+150,86);
 $pdf->MultiCell(0, 12, "{$currency_code} " . convertNumber($originalamt), "", 'L');
 //paymentvoucher AMT in Text label block (8)
 $pdf->SetXY($xmargin, 45);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(30, 12, "DESCRIPTION :", "", 0, 'L');
 $pdf->SetFont("Arial", "", 10);
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 9, $pdf->GetX() + 155, $pdf->GetY() + 9);
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 16, $pdf->GetX() + 155, $pdf->GetY() + 16);
示例#24
0
 public function pdfcreateAction()
 {
     require "lib/fpdf/fpdf.php";
     //Page footer
     function Footer()
     {
         //Position at 1.5 cm from bottom
         $this->SetY(-15);
         //Arial italic 8
         $this->SetFont('Arial', 'I', 8);
         //Page number
         $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
     }
     $pdf = new FPDF();
     $pdf->AliasNbPages();
     $todate = date("D M j Y");
     $time = date(" G:i:s T");
     $storePhone = Mage::getStoreConfig('general/store_information/phone');
     $store_email = Mage::getStoreConfig('trans_email/ident_support/email');
     $freeSubTotal = Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal');
     $session = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
     //print_r($session);die;
     $img_path = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/logo_print.gif';
     $telephone = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/telephone.png';
     $mail = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/mail.png';
     $indianrupee = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/rupee.png';
     $indian_rupee_symbol = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/total.png';
     $indian_rupee = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/savings.png';
     $sub_total = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/sub-total1.png';
     $shipping = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/shipping.png';
     $discount_image = Mage::getBaseUrl() . 'skin/frontend/default/zoffio/images/discount.png';
     $store_address = Mage::getStoreConfig('general/store_information/address');
     $split_store_address = explode(',', $store_address);
     $pdf->AddPage();
     $linestyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 10, 'color' => array(255, 0, 0));
     $pdf->Image($img_path, 10, 20, 31, 20, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->SetX(100);
     $pdf->SetY(25);
     $pdf->SetFont('arial', 'B', 13);
     $pdf->Cell(180, 0, 'Quotation', 2, 2, 'C');
     $pdf->Line(90, 27, 110, 27, $linestyle);
     $pdf->SetX(100);
     $pdf->SetY(25);
     $pdf->SetFont('arial', 'B', 11);
     $pdf->Cell(0, 0, $split_store_address[0], 0, 0, 'R');
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 10, $split_store_address[1] . ',' . $split_store_address[2] . ',' . $split_store_address[3], 0, 0, 'R');
     $pdf->Cell(0, 20, $split_store_address[4] . ',' . $split_store_address[5], 0, 0, 'R');
     $pdf->Cell(0, 30, $split_store_address[6], 0, 0, 'R');
     $pdf->Line(10, 49, 200, 49, $linestyle);
     $pdf->SetX(20);
     $pdf->SetY(38);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'VAT/TIN :  ', 0, 0, 'L');
     $pdf->SetX(25);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' 29471119182', 0, 0, 'L');
     $pdf->SetX(85);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'CST No:  ', 0, 0, 'L');
     $pdf->SetX(98);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' 29471119182', 0, 0, 'L');
     $pdf->SetX(150);
     $pdf->SetFont('arial', 'B', 9);
     $pdf->Cell(0, 30, 'PAN No :  ', 0, 0, 'L');
     $pdf->SetX(164);
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, ' AALCA1282E', 0, 0, 'L');
     $pdf->Line(10, 57, 200, 57, $linestyle);
     $pdf->Line(10, 72, 200, 72, $linestyle);
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(20);
     $pdf->SetY(45);
     $pdf->Cell(0, 35, 'QUOTATION DATE : ', 0, 0, 'L');
     $pdf->SetX(125);
     $pdf->Cell(0, 35, 'FOR ANY QUERIES : ', 0, 0, 'L');
     $pdf->SetFont('arial', 'B', 9);
     $pdf->SetX(20);
     $pdf->SetY(50);
     $pdf->Cell(0, 35, $todate . ', ' . $time, 0, 0, 'L');
     $pdf->SetX(127);
     $pdf->Image($telephone, 125, 66, 3, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Cell(0, 35, '+91-' . $storePhone, 0, 0, 'L');
     $pdf->Image($mail, 155, 66, 3, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->SetX(157);
     $pdf->Cell(0, 35, ' : ' . $store_email, 0, 0, 'L');
     $pdf->SetX(21);
     $pdf->SetY(60);
     $pdf->SetFont('arial', '', 9);
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $firstname = $customer->getFirstname();
     } else {
         $firstname = 'Customer';
     }
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 30, 'Dear ' . $firstname . ',', 0, 0, 'L');
     //$pdf->SetX(20);
     $pdf->SetY(80);
     $pdf->Cell(0, 1, 'Thank you for your interest in buying from us. Please find the below details of your selected products', 0, 0, 'L');
     $pdf->SetFont('arial', 'B', 8);
     //$pdf->SetX(10);
     $pdf->SetY(90);
     //$pdf->SetX(10);
     $pdf->Cell(7, 10, 'S.No', 1, 0, 'C');
     $pdf->Cell(100, 10, 'Products', 1, 0, 'L');
     $pdf->Cell(20, 10, 'SKU', 1, 0, 'C');
     $pdf->Cell(20, 10, 'Price', 1, 0, 'C');
     $pdf->Image($indianrupee, 152, 94, 3, 2, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Image($indianrupee, 197, 94, 3, 2, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false);
     $pdf->Cell(10, 10, 'Qty', 1, 0, 'C');
     $pdf->Cell(15, 10, 'Tax (%)', 1, 0, 'C');
     $pdf->Cell(20, 10, 'Sub Total', 1, 1, 'L');
     $j = 1;
     foreach ($session as $item) {
         if (!$item->getParentItem()) {
             $i = 10;
             $pdf->SetFont('arial', '', 9);
             $product_name = wordwrap($item->getName(), 15, TRUE);
             $font_size = 14;
             $decrement_step = 0.1;
             $line_width = 100;
             while ($pdf->GetStringWidth($item->getName()) > 98) {
                 $pdf->SetFontSize($font_size -= $decrement_step);
             }
             $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
             $item_total = ceil($item->getPriceInclTax()) * $item->getQty();
             $product_total = ceil($product->getPrice()) * $item->getQty();
             $pdf->SetX(10);
             $pdf->Cell(7, $i, $j, 1, 0, 'C');
             $pdf->Cell($line_width, 10, $item->getName(), 1, 0, 'L');
             //$pdf->Cell(50,$i,$product_name, 1,0,'C');
             $pdf->Cell(20, $i, $item->getSku(), 1, 0, 'C');
             $pdf->Cell(20, $i, number_format($item->getPriceInclTax(), 2), 1, 0, 'C');
             $pdf->Cell(10, $i, $item->getQty(), 1, 0, 'C');
             if ($product->getTypeId() == 'bundle') {
                 $pdf->Cell(15, $i, '-', 1, 0, 'C');
             } else {
                 $pdf->Cell(15, $i, number_format($item['tax_percent'], 1), 1, 0, 'C');
             }
             $pdf->Cell(20, $i, number_format($item->getPriceInclTax() * $item->getQty(), 2), 1, 1, 'C');
             $total = $total + $item->getPriceInclTax() * $item->getQty();
             $saving = $saving + $product_total;
             $j++;
         }
     }
     $totals1 = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
     $subtotal = $totals1["subtotal"]->getValue();
     $grandtotal = $totals1["grand_total"]->getValue();
     if (isset($totals1['discount']) && $totals1['discount']->getValue()) {
         $discount = number_format($totals1['discount']->getValue(), 2);
         //Discount value if applied
     }
     // exit;
     if ($total > $freeSubTotal) {
         $shipping_rate = '0.00';
     } else {
         if ($total < $freeSubTotal) {
             $shipping_rate = Mage::getStoreConfig('carriers/flatrate/price');
             $shipping_rate = number_format($shipping_rate, 2);
             $totals = $grandtotal + $shipping_rate;
         }
     }
     $pdf->SetFont('arial', '', 10);
     $saving_amount = '  ' . $saving - $total;
     $customer_care = Mage::getStoreConfig('general/store_information/phone');
     $pdf->Cell(192, 10, $pdf->Image($sub_total, 150, $pdf->GetY() + 4, 27, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . number_format($total, 2), 1, 2, 'R');
     //$pdf->Cell(192,10,'Sub Total:'.number_format($total,2), 1,2,'R');
     $pdf->Cell(192, 10, $pdf->Image($shipping, 142, $pdf->GetY() + 4, 27, 3, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . $shipping_rate, 1, 2, 'R');
     //$pdf->Cell(192,10,'Shipping & Handling:	'.$shipping_rate, 1,2,'R');
     if ($discount != NULL) {
         $pdf->Cell(192, 10, $pdf->Image($discount_image, 142, $pdf->GetY() + 4, 26, 2.5, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . $discount, 1, 2, 'R');
         //$pdf->Cell(192,10,'Discount Amount:	'.$discount, 1,2,'R');
     }
     $pdf->SetFont('arial', 'B', 12);
     $pdf->Cell(96, 10, $pdf->Image($indian_rupee, 20, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '   ' . number_format($saving_amount, 2), 1, 0, 'C');
     if ($totals != NULL) {
         $pdf->Cell(96, 10, $pdf->Image($indian_rupee_symbol, 115, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '  ' . number_format($totals, 2), 1, 0, 'C');
     } else {
         $pdf->Cell(96, 10, $pdf->Image($indian_rupee_symbol, 115, $pdf->GetY() + 3, 27, 4, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false) . '  ' . number_format($grandtotal, 2), 1, 0, 'C');
     }
     $pdf->SetX(5);
     $statement1 = 'We would be happy to fulfill your order at the earliest.';
     $statement1_1 = ' Zoffio helps you save upto 60% on all your office needs and guarantees ';
     $statement1_2 = 'you the best quality original products';
     $statement2 = 'Complete your order today so as not to lose out of the savings!';
     $statement3 = 'You can also contact our customer care support team for more information.';
     $pdf->SetFont('arial', '', 9);
     $pdf->Cell(0, 45, $statement1, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(80);
     $pdf->Cell(0, 45, $statement1_1, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(5);
     $pdf->Cell(0, 55, $statement1_2, 0, 0, 'L');
     $pdf->SetFont('arial', '', 9);
     $pdf->SetX(5);
     $pdf->Cell(0, 70, $statement2, 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 80, $statement3 . '- +91- ' . $customer_care, 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 95, 'Best Wishes', 0, 0, 'L');
     $pdf->SetX(5);
     $pdf->Cell(0, 105, 'Zoffio Team', 0, 0, 'L');
     $pdf->SetTextColor(0, 8, 8);
     $pdf->SetFont('arial', '', 7);
     $pdf->SetY(-15);
     $pdf->Cell(0, -10, '(This quotation is generated from the website Zoffio.com in real time. As prices are dynamic, so please recheck the price before confirmation)', 0, 0, 'C');
     $pdf->Output('Zoffio-quotation.pdf', 'D');
 }
示例#25
0
$pdf->Cell(40, 5, "Mata Pelajaran", 1, 0, 'C', true);
$pdf->Cell(20, 5, "Kelas", 1, 0, 'C', true);
$pdf->Cell(30, 5, "Nilai Akhir", 1, 0, 'C', true);
$pdf->Cell(30, 5, "Predikat (NA)", 1, 0, 'C', true);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
//membuat halaman
$no = 1;
//fungsi mengatur dan posisi table x dan y
$pdf->SetXY(15, 65);
//membuat baris tabel
while (list($kd_mapel, $mapel, $kelas, $nilai) = mysql_fetch_row($hasilnya2)) {
    $pdf->Cell(10, 5, $no, 1, 0, 'C');
    $pdf->Cell(40, 5, $kd_mapel, 1, 0, 'C');
    $pdf->Cell(40, 5, $mapel, 1, 0, 'C');
    $pdf->Cell(20, 5, $kelas, 1, 0, 'C');
    $pdf->Cell(30, 5, $nilai, 1, 0, 'C');
    $pdf->Cell(30, 5, $nilai, 1, 0, 'C');
    $y = 65 + 5 * $no;
    $no++;
    $pdf->SetXY(15, $y);
}
//fungsi show halaman
$pdf->SetY(-15);
//buat garis horizontal
$pdf->Line(7, $pdf->GetY(), 200, $pdf->GetY());
//Arial italic 9
$pdf->SetFont('Arial', 'I', 7);
//nomor halaman
$pdf->Cell(0, -10, 'Halaman ' . $pdf->PageNo() . ' dari {nb}', 0, 0, 'R');
$pdf->Output();
$pdf->Cell(100, 0, utf8_decode('Número de informes: ' . $numeroInformes));
//EL GRUPO CONOCE LAS NORMAS
$datoConoceNormas = mysql_query("SELECT * FROM evaluaciongeneral WHERE grupo='{$grupo}' AND conocenormas='No'", $link);
$noConoceNormas = mysql_num_rows($datoConoceNormas);
$conoceNormas = $numeroInformes - $noConoceNormas;
$pdf->SetFont('Arial', 'B', 12);
$pdf->Ln(10);
$pdf->Cell(0, 0, utf8_decode('El grupo conoce las normas: '));
$pdf->Ln(10);
$pdf->SetFont('Arial', '', 12);
$textoConoceNormas = "Sí:" . round($conoceNormas / $numeroInformes * 100, 2) . "% (" . $conoceNormas . " respuestas)";
$textoNoConoceNormas = "No: " . round($noConoceNormas / $numeroInformes * 100, 2) . "% (" . $noConoceNormas . " respuestas)";
$pdf->Cell(80, 0, utf8_decode($textoConoceNormas));
$pdf->SetFillColor(0, 255, 0);
$pdf->SetDrawColor(0, 0, 0);
$pdf->Rect($pdf->GetX(), $pdf->GetY() - 2, $conoceNormas / $numeroInformes * 100, 3, FD);
$pdf->Ln(5);
$pdf->Cell(80, 0, utf8_decode($textoNoConoceNormas));
$pdf->SetFillColor(255, 0, 0);
$pdf->SetDrawColor(0, 0, 0);
$pdf->Rect($pdf->GetX(), $pdf->GetY() - 2, $noConoceNormas / $numeroInformes * 100, 3, FD);
$pdf->Ln(5);
//$pdf->Multicell(160,5,  utf8_decode($textoConoceNormas),1,'L',0);
$pdf->Ln(5);
//EL GRUPO CUMPLE LAS NORMAS
$datoCumpleNormas = mysql_query("SELECT * FROM evaluaciongeneral WHERE grupo='{$grupo}' AND respetanormas='No'", $link);
$noCumpleNormas = mysql_num_rows($datoCumpleNormas);
$cumpleNormas = $numeroInformes - $noCumpleNormas;
/*
$textoCumpleNormas="El grupo cumple las normas: "."\n Sí:".(($cumpleNormas/$numeroInformes)*100)."% (".$cumpleNormas." respuestas)"."\n"."No: ".(($noCumpleNormas/$numeroInformes)*100)."% (".$noCumpleNormas." respuestas)";
//$pdf->SETXY(10,45);
示例#27
0
 $pdf->SetTextColor(0, 0, 0);
 // Schriftart festlegen
 $pdf->SetFont('Times', '', 11);
 $pdf->Write(5, utf8_decode(sprintf(', %s', $mitglied['vorname'])));
 if ($mitglied['fl_dienst_absprache'] == 'J') {
     // neue Position auf der X-Achse
     $pdf->SetX(80);
     // Schriftart festlegen
     $pdf->SetFont('Times', 'B', 11);
     $pdf->SetTextColor(255, 0, 0);
     $pdf->Write(5, utf8_decode('(n.n.R.)'));
 }
 // Schriftart festlegen
 $pdf->SetFont('Times', '', 11);
 $pdf->SetTextColor(0, 0, 0);
 $y_alt = $pdf->GetY();
 $offset = 0;
 if (!empty($mitglied['telefon1'])) {
     $pdf->SetX(110);
     $pdf->Write(5, utf8_decode(sprintf('%s (privat)', $mitglied['telefon1'])));
     $y += 5;
     $offset += 5;
 }
 if (!empty($mitglied['telefon2'])) {
     $pdf->SetXY(110, $y);
     $pdf->Write(5, utf8_decode(sprintf('%s (dienstl.)', $mitglied['telefon2'])));
     $y += 5;
     $offset += 5;
 }
 if (!empty($mitglied['mobil1'])) {
     $pdf->SetXY(110, $y);
示例#28
0
$pdf->MultiCell(0, 10, 'WYWIAD', 0, "C");
$sql = "select * from wizyty_inf where wizyty_inf.id_wiz = " . $_GET['wiz'];
$result = mysql_query($sql);
$pac_inf = @mysql_fetch_array($result);
#
$pdf->Ln(5);
$pac_inf['wyw'] = iconv('UTF-8', 'windows-1250//TRANSLIT', $pac_inf[1]);
$pac_inf['bad'] = iconv('UTF-8', 'windows-1250//TRANSLIT', $pac_inf[2]);
$pac_inf['zalecenia'] = iconv('UTF-8', 'windows-1250//TRANSLIT', $pac_inf[3]);
$pdf->MultiCell(0, 5, $pac_inf['wyw'], 0, "J");
$pdf->Ln(10);
$pdf->MultiCell(0, 10, 'BADANIE', 0, "C");
$pdf->MultiCell(0, 5, $pac_inf['bad'], 0, "J");
$pdf->Ln(10);
$pdf->MultiCell(0, 10, 'ZALECENIA', 0, "C");
$pdf->MultiCell(0, 5, $pac_inf['zalecenia'], 0, "J");
$osy = $pdf->GetY();
if ($_SESSION['uzytk']['podpis'] != '') {
    $pdf->Image('../img/pieczatki/' . $_SESSION['uzytk']['podpis'], 135, $osy, 46);
}
if ($_GET['type'] == d) {
    $pdf->Output("../print/" . $_GET['wiz'] . ".pdf", "F");
    #shell_exec("lpr ../print/".$_GET['wiz'].".pdf");
    shell_exec("lp -o media=A4 -d " . $_SESSION['global']['default_printer'] . " ../print/" . $_GET['wiz'] . ".pdf | lpstat | lpstat -t");
    #echo "<pre>$output</pre>";
    #echo "Im Here";
    #śsleep(2);
    shell_exec("rm ../print/" . $_GET['wiz'] . ".pdf");
} else {
    $pdf->Output($pac['naz'] . " " . $pac['imie'] . " - " . date("Ymd"), "D");
}
示例#29
0
 $pdf->Cell(10, 12, "No. :", "", 0, 'L');
 $pdf->SetFont("Times", "B", 10);
 $pdf->Cell(0, 12, "{$receipt_prefix}{$receipt_no}", "", 0, 'R');
 //paymentvoucher Date label block (5)
 $pdf->SetXY($xmargin + 145, 18);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(10, 12, "Date :", "", 0, 'L');
 $pdf->SetFont("times", "B", 10);
 $pdf->Cell(0, 12, "{$receipt_date}", "", 0, 'R');
 //Receipt From label block (6)
 $pdf->SetXY(10, 30);
 // ori Y=60
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(40, 12, "Received From :", "", 0, 'L');
 $pdf->SetFont("Times", "B", 10);
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 9, $pdf->GetX() + 150, $pdf->GetY() + 9);
 $pdf->Cell(0, 12, "{$paidfrom}", "", 0, 'L');
 //Receipt AMT in Text label block (7)
 $pdf->SetXY(10, 38);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(40, 12, "The Sum Of :", "", 0, 'L');
 $pdf->SetFont("Times", "", 10);
 $pdf->Line($pdf->GetX(), $pdf->GetY() + 9, $pdf->GetX() + 150, $pdf->GetY() + 9);
 //$pdf->Line($pdf->GetX(),86,$pdf->GetX()+150,86);
 //echo ucwords("SAAAS SDA asDDS");
 $txt_sum = ucwords(strtolower(convertNumber($originalamt)));
 $pdf->MultiCell(0, 10, $currency_code . " " . $txt_sum, "", 'L');
 //Receipt AMT in Text label block (8)
 $pdf->SetXY(10, 45);
 $pdf->SetFont("Times", "", 10);
 $pdf->Cell(40, 10, "Description :", "", 0, 'L');
示例#30
0
 /**
  * Get the data needed for a downloadable version of the report (all data,
  * no paging necessary) and format it accordingly for the download file
  * type.
  *
  * NOTE: It is expected that the valid format types will be overridden in
  * an extended report class as the array is empty by default.
  *
  * @param string $format A valid format type.
  */
 function download($format)
 {
     global $CFG;
     $output = '';
     if (empty($this->data)) {
         return $output;
     }
     $filename = !empty($this->title) ? $this->title : 'report_download';
     switch ($format) {
         case 'csv':
             $filename .= '.csv';
             header("Content-Transfer-Encoding: ascii");
             header("Content-Disposition: attachment; filename={$filename}");
             header("Content-Type: text/comma-separated-values");
             $row = array();
             foreach ($this->headers as $header) {
                 $row[] = $this->csv_escape_string(strip_tags($header));
             }
             echo implode(',', $row) . "\n";
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $row = array();
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $row[] = $this->csv_escape_string($datum->{$id});
                     } else {
                         $row[] = '""';
                     }
                 }
                 echo implode(',', $row) . "\n";
             }
             break;
         case 'excel':
             require_once $CFG->libdir . '/excellib.class.php';
             $filename .= '.xls';
             /// Creating a workbook
             $workbook = new MoodleExcelWorkbook('-');
             /// Sending HTTP headers
             $workbook->send($filename);
             /// Creating the first worksheet
             $sheettitle = get_string('studentprogress', 'reportstudentprogress');
             $myxls =& $workbook->add_worksheet($sheettitle);
             /// Format types
             $format =& $workbook->add_format();
             $format->set_bold(0);
             $formatbc =& $workbook->add_format();
             $formatbc->set_bold(1);
             $formatbc->set_align('center');
             $formatb =& $workbook->add_format();
             $formatb->set_bold(1);
             $formaty =& $workbook->add_format();
             $formaty->set_bg_color('yellow');
             $formatc =& $workbook->add_format();
             $formatc->set_align('center');
             $formatr =& $workbook->add_format();
             $formatr->set_bold(1);
             $formatr->set_color('red');
             $formatr->set_align('center');
             $formatg =& $workbook->add_format();
             $formatg->set_bold(1);
             $formatg->set_color('green');
             $formatg->set_align('center');
             $rownum = 0;
             $colnum = 0;
             foreach ($this->headers as $header) {
                 $myxls->write($rownum, $colnum++, $header, $formatbc);
             }
             foreach ($this->data as $datum) {
                 if (!is_object($datum)) {
                     continue;
                 }
                 $rownum++;
                 $colnum = 0;
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $myxls->write($rownum, $colnum++, $datum->{$id}, $format);
                     } else {
                         $myxls->write($rownum, $colnum++, '', $format);
                     }
                 }
             }
             $workbook->close();
             break;
         case 'pdf':
             require_once $CFG->libdir . '/fpdf/fpdf.php';
             $filename .= '.pdf';
             $newpdf = new FPDF('L', 'in', 'letter');
             $marginx = 0.75;
             $marginy = 0.75;
             $newpdf->setMargins($marginx, $marginy);
             $newpdf->SetFont('Arial', '', 9);
             $newpdf->AddPage();
             $newpdf->SetFont('Arial', '', 16);
             $newpdf->MultiCell(0, 0.2, $this->title, 0, 'C');
             $newpdf->Ln(0.2);
             $newpdf->SetFont('Arial', '', 8);
             $newpdf->SetFillColor(225, 225, 225);
             $heights = array();
             $widths = array();
             $hmap = array();
             $rownum = 0;
             /// PASS 1 - Calculate sizes.
             foreach ($this->headers as $id => $header) {
                 $widths[$id] = $newpdf->GetStringWidth($header) + 0.2;
             }
             $row = 0;
             foreach ($this->data as $datum) {
                 if (!isset($heights[$row])) {
                     $heights[$row] = 0;
                 }
                 foreach ($this->headers as $id => $header) {
                     if (isset($datum->{$id})) {
                         $width = $newpdf->GetStringWidth($datum->{$id}) + 0.2;
                         if ($width > $widths[$id]) {
                             $lines = ceil($width / $widths[$id]);
                             $widths[$id] = $width;
                         } else {
                             $lines = 1;
                         }
                         $height = $lines * 0.2;
                         if ($height > $heights[$row]) {
                             $heights[$row] = $height;
                         }
                     }
                 }
                 $row++;
             }
             /// Calculate the width of the table...
             $twidth = 0;
             foreach ($widths as $width) {
                 $twidth += $width;
             }
             /// Readjust the left margin according to the total width...
             $marginx = (11.0 - $twidth) / 2.0;
             $newpdf->setMargins($marginx, $marginy);
             foreach ($this->headers as $id => $header) {
                 $text = str_replace(' ', "\n", $header);
                 $newpdf->Cell($widths[$id], 0.2, "{$text}", 1, 0, 'C', 1);
             }
             $newpdf->Ln();
             $row = 0;
             foreach ($this->data as $datum) {
                 if (is_array($datum) && strtolower($datum[0]) == 'hr') {
                     $curx = $newpdf->GetX();
                     $cury = $newpdf->GetY() + 0.1;
                     $endx = 0;
                     $endy = $cury;
                     foreach ($widths as $width) {
                         $endx += $width;
                     }
                     $newpdf->Line($curx, $cury, $endx, $endy);
                     $newpdf->SetX($curx + 0.1);
                 } else {
                     foreach ($this->headers as $id => $header) {
                         $text = '';
                         if (isset($datum->{$id})) {
                             $text = $datum->{$id};
                         }
                         $newpdf->Cell($widths[$id], $heights[$row], $text, 0, 0, 'C', 0);
                     }
                 }
                 $newpdf->Ln();
                 $row++;
             }
             $newpdf->Output($filename, 'I');
             break;
         default:
             return $output;
             break;
     }
 }