public function viewBookingPDF(Request $request) { include app_path() . '\\fpdf\\fpdf.php'; //require(app_path().'/Http/Controllers/fpdf/fpdf.php'); if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $id = $_REQUEST['id']; //return view('pages.mybookings', ['booking' => bookingModel::findOrFail($id)] ); $pdf = new \FPDF(); $pdf->AddPage(); $pdf->SetFont("Arial", "B", 20); $pdf->Cell(0, 10, "Welcome to Lodgiify", 1, 1); $pdf->Cell(50, 10, "FirstName :", 1, 0); //$pdf->Cell(50,10,$booking[0]->checkin ,1,1); $pdf->output(); die; } }
/** * 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); }
public function download($page = 'noticeview') { define('FPDF_FONTPATH', APPPATH . 'plugins/fpdf/font/'); require APPPATH . 'plugins/fpdf/fpdf.php'; $this->load->helper('url'); if (!file_exists(APPPATH . '/views/noticeboard/' . $page . '.php')) { show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $data['name'] = "Nayeem"; $id = $_GET['id']; $file = base_url() . 'uploads/' . $id . '.jpg'; $type = ".jpg"; if (@getimagesize($file)) { $size = getimagesize($file); } else { $type = ".png"; $file = base_url() . 'uploads/' . $id . '.png'; $size = getimagesize(base_url() . 'uploads/' . $id . '.png'); } //$pdf = new FPDF('p','mm',array(210,300)); if ($size[0] > $size[1]) { $style = 'l'; } else { $style = 'p'; } $pdf = new FPDF($style, 'pt', array($size[0] * 3 / 4, $size[1] * 3 / 4)); $pdf->AddPage(); $pdf->setDisplayMode('fullpage'); //$pdf -> Image(base_url().'uploads/'.$id.'.png',20,20,170,260); $pdf->Image(base_url() . 'uploads/' . $id . "" . $type, 0, 0, 0, 0); // $pdf -> setFont ('times','B',20); // $pdf -> cell(200,30,"Title",0,1); $pdf->setFont('times', 'B', '20'); $pdf->write(10, "{$size['0']}, {$size['1']}"); $pdf->output($id . '.pdf', 'D'); //header('Location: ' .base_url(). 'index.php/noticeview/show?id='.$id); }
$pdf->Cell(0, 10, "Address : {$address}", 1, 0, "L"); //$pdf->Cell(-100,10,"Present Complaints : {$complents}",1,0,"C"); $pdf->Ln(); $pdf->Cell(0, 10, "Date of Admission : {$admitdate}", 1, 0, "L"); $pdf->Cell(-100, 10, "Date of discharge : {$dischargedate}", 1, 0, "C"); $pdf->Ln(); $pdf->Cell(0, 10, "Diagnosis : {$diagnosis}", 1, 0, "L"); $pdf->Ln(); $pdf->Cell(0, 10, "Treatment : {$treatement}", 1, 0, "L"); $pdf->Ln(); $pdf->Cell(0, 10, "Surgeon Name : {$surgeon}", 1, 0, "L"); $pdf->Cell(-100, 10, "Anasthesia Surgeon : {$anasthesiasurgeon}", 1, 0, "C"); $pdf->Ln(); $pdf->Cell(0, 10, "Delivery : {$delivery}", 1, 0, "L"); $pdf->Cell(-100, 10, "Anasthesia : {$anasthesia}", 1, 0, "C"); $pdf->Ln(); $pdf->SetFont("Arial", "B", 12); $pdf->Cell(0, 10, "Baby's Information", 1, 0, "L"); $pdf->SetFont("Arial", "", 10); $pdf->Ln(); $pdf->Cell(0, 10, "Date Of Birth : {$bdob}", 1, 0, "L"); $pdf->Cell(-100, 10, "Birth Time : {$btime}", 1, 0, "C"); $pdf->Ln(); $pdf->Cell(0, 10, "Weight : {$weight}", 1, 0, "L"); $pdf->Ln(); $pdf->Cell(0, 10, "Gender : Male = {$male} Female = {$female} Twins = {$twins}", 1, 0, "L"); $pdf->Ln(); $pdf->Cell(0, 10, "Status : {$status}", 1, 0, "L"); $pdf->Cell(-100, 10, "Asphxia : {$asphxia}", 1, 0, "C"); $pdf->output();
<?php require_once 'fpdf.php'; define('FPDF_FONTPATH', './font/'); //Zeichensatz anzeigen im PDF $font = 'ORION'; $pdf = new FPDF(); $pdf->AddFont($font, '', $font . '.php'); $pdf->SetFont($font, '', 15); $pdf->Open(); $pdf->AddPage(); $pdf->setFontSize(15); for ($i = 32; $i < 256; $i++) { $text .= " #{$i}: " . chr($i); } $pdf->write(10, $text); $pdf->output('test.pdf');
public function viewVehicleBookingPDF(Request $request) { $error = true; $user = $request->session()->get('user'); if (is_null($user)) { return redirect()->action('MainController@index'); } elseif ($user[0]->type == "tenant") { if (isset($request['id'])) { $bookingid = $request['id']; $error = false; } else { $bookingid = false; $error = true; } if ($error == false) { $bookings = vehiclebookingModel::where('id', '=', $bookingid)->get(); $driver = $bookings[0]->vehicle->driver; if ($driver = 0) { $x = 'NO'; } else { $x = 'Yes'; } $vehicleName = $bookings[0]->vehicle->vehicleName; $vehicleModel = $bookings[0]->vehicle->models; $vehicleCat = $bookings[0]->vehicle->category->vehiclecatname; $vehicleImage = $bookings[0]->vehicle->image; include app_path() . '\\fpdf\\fpdf.php'; if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $id = $_REQUEST['id']; $pdf = new \FPDF(); $pdf->AddPage(); $pdf->Rect(5, 5, 200, 287, 'D'); //For A4 $pdf->SetFont("Arial", "B", 30); $pdf->SetFillColor(36, 96, 84); $pdf->write(6, $pdf->Image('images/logo.png', 145, 10, -100), 1, 1); $pdf->SetFont("Arial", "B", 8); $pdf->Ln(30); $pdf->Cell(135); $pdf->Write(10, "Phone: 2612205/57139151"); $pdf->Ln(10); $pdf->Cell(135); $pdf->Write(10, "Email: Lokeshpravin@gmail.com"); $pdf->SetFont("Arial", "B", 30); $pdf->Write(10, "Welcome to Lodgiify"); $pdf->Ln(20); $pdf->SetFont("Arial", "B", 12); $pdf->Cell(20); $pdf->MultiCell(25, 6, "Booking Form:", 'LRT', 'L', 0); $pdf->Cell(20); $pdf->Cell(75, 10, "Full Name :", 1, 0); $pdf->Cell(75, 10, $user[0]->FirstName . ' ' . $user[0]->LastName, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "From :", 1, 0); $pdf->Cell(75, 10, $bookings[0]->fromdate, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "To :", 1, 0); $pdf->Cell(75, 10, $bookings[0]->todate, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Price :", 1, 0); $pdf->Cell(75, 10, 'Rs' . $bookings[0]->price, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Vehicle Name :", 1, 0); $pdf->Cell(75, 10, $vehicleName, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Type :", 1, 0); $pdf->Cell(75, 10, $vehicleCat, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Model : ", 1, 0); $pdf->Cell(75, 10, $vehicleModel, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "With driver : ", 1, 0); $pdf->Cell(75, 10, $x, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Transmission : ", 1, 0); $pdf->Cell(75, 10, $bookings[0]->vehicle->transmission, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 60, "Image : ", 1, 0); $pdf->Cell(75, 60, $pdf->Image('upload' . "/" . $vehicleImage, 118, 187, 50, 50), 1, 1); $pdf->Ln(45); $pdf->SetFont("Arial", "B", 10); $pdf->Cell(155); $pdf->Cell(0, 5, "Page " . $pdf->PageNo(), 0, 1); $pdf->output(); die; } } } else { return response()->view('pages.404', ['user' => $user], 404); } }
public function download() { define('FPDF_FONTPATH', APPPATH . 'plugins/fpdf/font/'); require APPPATH . 'plugins/fpdf/fpdf.php'; $this->load->helper('url'); $getmed = $this->dbroom->getmedical(); $getlau = $this->dbroom->getlaundry(); $data['mednil'] = 0; $data['launil'] = 0; if ($getmed->num_rows() == 0) { $data['mednil'] = 1; } if ($getlau->num_rows() == 0) { $data['launil'] = 1; } $pdf = new FPDF('p', 'mm', 'a4'); $pdf->AddPage(); $pdf->setDisplayMode('fullpage'); $pdf->setFont('times', 'B', '20'); if (!$data['mednil']) { $pdf->write(10, "\nStudents Asked for Medical Help\n\n"); $pdf->setFont('times', 'B', '15'); $pdf->cell(80, 10, "Name", 1, 0, 'C'); $pdf->cell(40, 10, "Room", 1, 0, 'C'); $pdf->cell(40, 10, "Phone", 1, 0, 'C'); $pdf->write(10, "\n"); foreach ($getmed->result() as $row) { $pdf->setFont('times', '', '15'); $pdf->cell(80, 10, $row->name, 1, 0, 'C'); $pdf->cell(40, 10, $row->room, 1, 0, 'C'); $pdf->cell(40, 10, $row->phone, 1, 0, 'C'); $pdf->write(10, "\n"); // $pdf -> cell(200,30,$row->room,1,1); // $pdf -> cell(200,30,$row->phone,1,1); } } $pdf->setFont('times', 'B', '20'); if (!$data['launil']) { $pdf->write(10, "\nStudents Asked for Laundry Service\n\n"); $pdf->setFont('times', 'B', '15'); $pdf->cell(80, 10, "Name", 1, 0, 'C'); $pdf->cell(40, 10, "Room", 1, 0, 'C'); $pdf->cell(40, 10, "Phone", 1, 0, 'C'); $pdf->write(10, "\n"); foreach ($getlau->result() as $row) { $pdf->setFont('times', '', '15'); $pdf->cell(80, 10, $row->name, 1, 0, 'C'); $pdf->cell(40, 10, $row->room, 1, 0, 'C'); $pdf->cell(40, 10, $row->phone, 1, 0, 'C'); $pdf->write(10, "\n"); // $pdf -> cell(200,30,$row->room,1,1); // $pdf -> cell(200,30,$row->phone,1,1); } } $pdf->output('service.pdf', 'D'); }