/** * 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); }
/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-{$task_list_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetTitle($task_list_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode(fullpage, single); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'C'); $pdf->Ln(); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(); $tasks = $task_list->getTasks(); $line = 0; // Column widths $w = array(10, 0, 0); // Header //for($i=0;$i<count($header);$i++) // $this->Cell($w[$i],7,$header[$i],1,0,'C'); //$this->Ln(); $pdf->SetFont('Arial', 'I', 14); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $pdf->SetTextColor(100, 200, 100); $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()); } else { $task_status = lang('open'); $pdf->SetTextColor(255, 0, 0); $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()); } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $pdf->Cell($w[0], 6, $line); $pdf->Cell($w[2], 6, $task_status, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_completion_info, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_assignee, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell($w[2], 6, $task->getText(), "TLRB"); $pdf->Ln(); } } $pdf->Output($download_name, 'D'); } else { $download_name = "{$project_name}-{$task_list_name}-tasks.txt"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }
// si la variable $gepiSchoolName est vide alors on cherche les informations dans la base if ( empty($gepiSchoolName) ) { $gepiSchoolName=getSettingValue('gepiSchoolName'); } // création du document $pdf->SetCreator($gepiSchoolName); // auteur du document $pdf->SetAuthor($gepiSchoolName); // mots clé $pdf->SetKeywords(''); // sujet du document $pdf->SetSubject('Bilan journalier des absences'); // titre du document $pdf->SetTitle('Bilan journalier des absences'); // méthode d'affichage du document à son ouverture $pdf->SetDisplayMode('fullwidth', 'single'); // compression du document $pdf->SetCompression(TRUE); // change automatiquement de page à 5mm du bas $pdf->SetAutoPageBreak(TRUE, 5); /* **************************** */ /* début de la boucle des pages */ // comptage du nombre de page traité $nb_page_traite = 0;
<?php session_start(); require_once '../includes/connecti.php'; require_once '../includes/funcs.inc.php'; if (isset($_GET['report']) && $_GET['report'] == 'true') { $MAX_LIMIT = 8; require_once '../includes/fpdf.php'; $pdf = new FPDF('L', 'cm', array(7.7, 15.9)); $pdf->SetAuthor("*****@*****.**"); $pdf->SetSubject("Cheque"); $pdf->SetTitle("Cheque"); $pdf->SetCreator("Imran Zahid"); $pdf->AddPage(); $pdf->SetFont('Arial', '', 12); $amt = explode(' ', convertCurrency($_GET['amount']) . " Only."); $str1 = ""; $sep = ""; $w = 0; $counter = 0; do { $temp = $str1 . $sep . $amt[$counter]; $w = $pdf->GetStringWidth($temp); if ($w < $MAX_LIMIT) { $str1 .= $sep . $amt[$counter]; $sep = " "; $counter++; } if ($counter > count($amt)) { break; }
$listOfSignatories["id"] = $signatorial_model->getSign_ID(); $clearance_model = new ClearanceStatus(); foreach ($listOfSignatories["id"] as $key => $value) { $status = $clearance_model->getOverallSignatoryClearanceStatus($stud_id, $value, $current_sysemID); 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() {
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("£", 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; }
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // // $Id: gen_facture.php 532 2007-06-14 10:39:19Z thierry $ // Génère un PDF pour une facture require "../inc/main.php"; # If user is not logged, generate a PDF with an explicit error message if (!isset($_SESSION['id_user']) || $_SESSION['id_user'] < 1) { $pdf = new FPDF('P', 'mm', 'A4'); $pdf->SetMargins(10, 10, 10); $pdf->SetDisplayMode('fullwidth'); $pdf->SetAutoPageBreak(true); $pdf->AddPage(); $pdf->SetFont('Arial', '', 12); $pdf->Cell(190, 20, _("You are not authenticated")); $pdf->SetSubject(_('Error')); $pdf->SetTitle(_('Error')); $pdf->Output(_("Error") . ".pdf", "I"); die; } # Check if the invoice id is defined if (!isset($_GET['id']) or !is_numeric($_GET['id'])) { die(_("Error: Missing invoice id")); } $docs = false; if ($_GET['docs'] == 1) { $docs = true; } $invoice = new Facture(); $filename = $invoice->generatePDF($_GET['id'], false, $target = 'file', $docs); header('Content-Type: application/pdf');
public function generar_pdf($id_cor, $id_direccion_gen) { $correspondencia = $this->ivss_model->core_parcial($id_cor)->result(); $direccion_general = $this->ivss_model->ver_direccion_general_especifica($id_direccion_gen); foreach ($correspondencia as $cor_item) { $id_cor_oficio = $cor_item->id_cor; $num_control_oficio = $cor_item->num_control; $dir_origen_oficio = $cor_item->dir_origen; $remitente_oficio = $cor_item->remitente; $dir_destino_oficio = $cor_item->dir_destino; $asunto_oficio = $cor_item->asunto; $descripcion_oficio = $cor_item->descripcion; $fecha_crea_oficio = $cor_item->fecha_creacion; } $datos_director = $this->ivss_model->ver_dir_gen_especifica2($dir_destino_oficio)->result(); foreach ($datos_director as $dir) { $nombre_director = $dir->nombre_director; $resolucion_director = $dir->resolucion_director; } $this->load->library('fpdf/fpdf'); $pdf = new FPDF('P'); $pdf->AddPage(); $pdf->SetTitle("correspondencia", true); $pdf->SetFont('Arial', 'B', 16); $pdf->Image($this->config->base_url() . 'fronted/img/banner_institucional.png', 20, 8, 170); $pdf->AliasNbPages(); $pdf->SetSubject("Sistema de correspondencia"); $pdf->Image($this->config->base_url() . 'fronted/img/logogrande.png', 20, 25, 17); $pdf->SetFont('Arial', '', 9); $pdf->Text(68, 30, "REPUBLICA BOLIVARIANA DE VENEZUELA"); $pdf->Text(42, 40, "MINISTERIO DEL PODER POPULAR PARA EL PROCESO SOCIAL DEL TRABAJO"); $pdf->Text(62, 50, "INSTITUTO VENEZOLANO DE LOS SEGUROS SOCIALES"); $pdf->SetLeftMargin(20.0); $pdf->SetRightMargin(20.0); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 70, "OFICIO:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 70, $num_control_oficio); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 80, "PARA:"); $pdf->SetFont('Arial', 'b', 12); #$pdf->Text(44,80,strtoupper(utf8_decode($nombre_director))); $pdf->Text(44, 80, strtoupper(utf8_decode("JACINTO PEREZ BONALDE SANCHEZ"))); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 90, utf8_decode($dir_destino_oficio)); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 100, "DE:"); $pdf->SetFont('Arial', 'b', 12); $pdf->Text(44, 100, utf8_decode($remitente_oficio)); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 110, utf8_decode(end(explode("-", $dir_origen_oficio)))); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 120, "FECHA:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 120, $fecha_crea_oficio); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 130, "ASUNTO:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 130, utf8_decode($asunto_oficio)); $pdf->SetXY(10, 140); $pdf->SetFont('Arial', '', 10); $pdf->SetTopMargin(2.0); $pdf->SetLeftMargin(20.0); $pdf->SetRightMargin(20.0); $pdf->MultiCell(0, 7, utf8_decode($descripcion_oficio)); $pdf->SetFont('Arial', 'b', 10); $pdf->Text(93, 245, "Atentamente"); $pdf->Line(50, 264, 160, 264); #$pdf->Image($this->config->base_url().'fronted/img/FIRMADIGITAL.png',52,230,115); $pdf->SetFont('Arial', '', 10); $pdf->Text(75, 268, utf8_decode($remitente_oficio)); $pdf->SetFont('Arial', '', 10); $pdf->Text(88, 272, utf8_decode("Director general")); $pdf->SetFont('Arial', '', 10); $pdf->Text(76, 276, utf8_decode("Según resolución:" . $resolucion_director)); $pdf->Output('oficio_' . $num_control_oficio, 'I'); #tabla /* $cabecera=array('Usuario', 'Total asignados', 'Ejecutados'); $pdf->SetXY(10,30); //Seleccionamos posición $pdf->SetFont('Arial','B',10); //Fuente, Negrita, tamaño foreach($cabecera as $columna){ //Parámetro con valor 2, cabecera vertical $pdf->Cell(50,7, utf8_decode($columna),1, 0,'L'); } $pdf->SetXY(10,31); $pdf->Ln();//Salto de línea para generar otra fila $pdf->Ln();//Salto de línea para generar otra fila foreach($cabecera as $fila){ //Atención!! el parámetro valor 0, hace que sea horizontal $pdf->Cell(50,7, utf8_decode($fila),1, 0 , '' ); } */ #llave clase. }
/** * * Wrapper to solve utf-8 issues. * * @param string $subject * * @param bool $isUTF8 Defaults to TRUE. * * @return void * */ public function SetSubject($subject, $isUTF8 = TRUE) { parent::SetSubject($subject, $isUTF8); }
} else { $t_cpe = $t_cpe + 1; } } // mode paysage, a4, etc. $pdf=new FPDF('P','mm','A4'); $pdf->Open(); $pdf->SetAutoPageBreak(false); // champs facultatifs $pdf->SetAuthor(''); $pdf->SetCreator('créé avec Fpdf'); $pdf->SetTitle('Titre'); $pdf->SetSubject('Sujet'); // on charge les 83 gfx... $pdf->SetMargins(10,10); for ($i=0; $i<$nb; $i++) { $pdf->AddPage(); // information logo $L_max_logo='75'; // Longeur maxi du logo $H_max_logo='75'; // hauteur maxi du logo $logo = '../../images/'.getSettingValue('logo_etab'); $valeur=redimensionne_logo($logo, $L_max_logo, $H_max_logo); $X_logo='23'; $Y_logo='10'; $L_logo=$valeur[0]; $H_logo=$valeur[1]; //logo
$consulta2 = "SELECT * FROM CIUDADANO WHERE ID_CIUDADANO= '" . $id_ciudadano . "'"; $stid2 = oci_parse($conex, $consulta2); if (!$stid2) { echo "Error"; } $r2 = oci_execute($stid2); if (!$r2) { echo "Error"; } $resultado2 = oci_fetch_assoc($stid2); $pdf->AddPage(); $pdf->SetTitle("Constancia de denuncia", true); $pdf->SetFont('Arial', 'B', 14); $pdf->Text(80, 30, 'Planilla de denuncia'); $pdf->AliasNbPages(); $pdf->SetSubject("Planilla de denuncia"); $pdf->Image('../../public_html/imagenes/banner_institucional.png', 20, 6, 170); $pdf->Image('../../public_html/imagenes/logoclaro.png', 40, 50, 120); $pdf->SetXY(10, 100); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(20, 40); $pdf->SetTextColor(255, 255, 255); $pdf->SetFillColor(18, 4, 155); $pdf->SetFillColor(35, 65, 129); $pdf->SetFont('Arial', 'B', 9); $pdf->Cell(170, 7, utf8_decode('Datos del Trabajador'), 1, 0, 'C', true); $pdf->Ln(); $pdf->SetXY(20, 47); $pdf->SetTextColor(0, 0, 0); $pdf->SetFillColor(255, 255, 255, false); $pdf->Cell(40, 7, utf8_decode('Cédula'), 1, 0, 'C', false);
/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF("P", "mm"); $pdf->AddPage(); $pdf->SetTitle($project_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode('fullpage', 'single'); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'B', 0, 'C'); $pdf->Ln(14); $w = array(0 => 12, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(14); $tasks = $task_list->getTasks(); $pdf->SetFont('Arial', 'I', 14); $pdf->SetFillColor(230, 230, 230); $pdf->Cell($w[1], 6, '#', 1, 0, 'C', true); $pdf->Cell($w[3], 6, lang('status'), 1, 0, 'C', true); $pdf->Cell($w[10], 6, lang('info'), 1, 0, 'C', true); $pdf->Cell(0, 6, lang(user), 1, 0, 'C', true); $pdf->Ln(); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $task_status_color_R = 0; $task_status_color_G = 150; $task_status_color_B = 0; $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()) . ' @ ' . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_status_color_R = 200; $task_status_color_G = 0; $task_status_color_B = 0; $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); $task_completion_info_color_R = 200; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()) . ' @ ' . format_time($task->getDueDate()); $task_completion_info_color_R = 0; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); $task_assignee_color_R = 0; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } else { $task_assignee = lang('not assigned'); $task_assignee_color_R = 200; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } $pdf->SetFillColor(245, 245, 245); $pdf->Cell($w[1], 6, $line, 1, 0, 'C', true); $pdf->SetTextColor($task_status_color_R, $task_status_color_G, $task_status_color_B); $pdf->Cell($w[3], 6, $task_status, 1, 0, 'C', true); $pdf->SetTextColor($task_completion_info_color_R, $task_completion_info_color_G, $task_completion_info_color_B); $pdf->Cell($w[10], 6, $task_completion_info, 1, 0, 'C', true); $pdf->SetTextColor($task_assignee_color_R, $task_assignee_color_G, $task_assignee_color_B); $pdf->Cell(0, 6, $task_assignee, 1, 0, 'C', true); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(); $pdf->MultiCell(0, 6, $task->getText(), 1); //$pdf->Ln(); } } $pdf->Output($download_name, 'I'); } if ($output == 'txt') { $download_name = "{$project_name}-tasks.txt"; $download_type = 'text/csv'; $txt_lang_1 = lang('project'); $txt_lang_2 = lang('milestone'); $txt_lang_3 = lang('task list'); $txt_lang_4 = lang('status'); $txt_lang_5 = lang('description'); $txt_lang_6 = lang('id'); $txt_lang_7 = lang('status'); $txt_lang_8 = lang('completion info'); $txt_lang_9 = lang('assigned to'); $s .= "{$txt_lang_1}\t{$txt_lang_2}\t{$txt_lang_3}\t{$txt_lang_4}\t{$txt_lang_5}\t{$txt_lang_6}\t{$txt_lang_7}\t{$txt_lang_8}\t{$txt_lang_9}"; $s .= "\n"; $task_lists = active_project()->getOpenTaskLists(); foreach ($task_lists as $task_list) { /*$s .= $task_list->getObjectName(); $s .= "\n"; $task_list_desc = $task_list->getDescription(); $task_list_desc = strtr($task_list_desc,"\r\n\t"," "); $task_list_desc_100 = substr($task_list_desc,0,100); $s .= $task_list_desc_100; $s .= "\n";*/ $milestone = $task_list->getMilestone(); $tasks = $task_list->getTasks(); foreach ($tasks as $task) { $s .= $project_name; $s .= "\t"; $milestone_name = lang(none); if ($milestone instanceof ProjectMilestone) { $milestone_name = $milestone->getName(); } $s .= $milestone_name; $s .= "\t"; $s .= $task_list->getObjectName(); $s .= "\t"; $task_list_name = $task_list->getName(); if ($task_list->isCompleted()) { $task_list_status = lang('completed'); } else { $task_list_status = lang('open'); } $s .= $task_list_status; $s .= "\t"; $task_list_desc2 = $task_list->getDescription(); $task_list_desc2 = strtr($task_list_desc2, "\r\n\t", " "); $task_list_desc2_100 = substr($task_list_desc2, 0, 50); $s .= $task_list_desc2_100; $s .= "\t"; $s .= $task->getId(); $s .= "\t"; if ($task->isCompleted()) { $task_status = lang('completed'); $task_completion_info = format_date($task->getCompletedOn()) . " @ " . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_completion_info = format_date($task->getDueDate()) . " @ " . format_time($task->getDueDate()); } $s .= $task_status; $s .= "\t"; $s .= $task_completion_info; $s .= "\t"; if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $s .= $task_assignee; $s .= "\n"; } } $download_contents = $s; download_headers($download_name, $download_type, strlen($download_contents), true); echo $download_contents; } else { $download_name = "{$project_name}-{$task_list_name}-tasks.csv"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }