本文整理汇总了PHP中Pdf类的典型用法代码示例。如果您正苦于以下问题:PHP Pdf类的具体用法?PHP Pdf怎么用?PHP Pdf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pdf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadPdf
public function downloadPdf()
{
// header("Content-type: text/html; charset: utf-8;");
require_once '/Data/ClassLib/Pdf.class.php';
$a = new \Pdf();
$a->setHtmlBody($this->html);
$a->build('downloadtest.pdf', 'D');
}
示例2: create
public function create()
{
$this->load->library('Mpdf');
$html = "<b>Ví Dụ</b><br />Xuất file PDF";
$mpdf = new Pdf();
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->WriteHTML($html);
$mpdf->Output("file/mpdf.pdf", 'I');
}
示例3: actionImprimir
public function actionImprimir()
{
// get your HTML raw content without any layouts or scrip
$pasostramite = pasostramite::find()->all();
$content = $this->renderPartial('_imprimir', ['pasostramite' => $pasostramite]);
$header = $this->renderPartial('_header', ['pasostramite' => $pasostramite]);
$pdf = new Pdf(['format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetHeader' => $header, 'SetFooter' => ['{PAGENO}']]]);
// return the pdf output as per the destination setting
return $pdf->render();
}
示例4: __construct
/**
* Constructor.
*
* @return void
*/
public function __construct($tagProperties = array())
{
$this->pdf = Pdf::singleton();
if (isset($tagProperties['ID'])) {
$this->id = $tagProperties['ID'];
if (!isset($this->pdf->linksIds[$this->id])) {
$this->pdf->linksIds[$this->id] = $this->pdf->AddLink();
}
$this->pdf->SetLink($this->pdf->linksIds[$this->id], -1);
}
}
示例5: actionImprimirFiltro
public function actionImprimirFiltro()
{
//echo'<pre>';print_r($_GET);echo'</pre>'; exit;
$fechaInicial = date("d-m-Y", strtotime($_GET['fechas']["filtro"]["fechaInicial"]));
$fechaFinal = date("d-m-Y", strtotime($_GET['fechas']["filtro"]["fechaFinal"]));
$formato = 'fecha_ft >= "' . $fechaInicial . '" and fecha_ft <= "' . $fechaFinal . '"';
$VisitasEscuelas = VisitasEscuelas::find()->where('fecha_ft >= :fechaInicial and fecha_ft <= :fechaFinal', ['fechaInicial' => $fechaInicial, 'fechaFinal' => $fechaFinal])->all();
$content = $this->renderPartial('_imprimir', ['VisitasEscuelas' => $VisitasEscuelas]);
$header = $this->renderPartial('_header', ['VisitasEscuelas' => $VisitasEscuelas]);
$pdf = new Pdf(['format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetHeader' => $header, 'SetFooter' => ['{PAGENO}']]]);
// return the pdf output as per the destination setting
return $pdf->render();
}
示例6: __construct
/**
* Constructor.
*
* Parse the tag attributes and add the new line to the document.
*
* @param array $tagProperties tag properties
* @return void
*/
public function __construct($tagProperties)
{
$pdf = Pdf::singleton();
$lineColor = $tagProperties['LINECOLOR'];
if ($lineColor != '') {
$drawColor = Xml2Pdf::convertColor($lineColor);
$pdf->SetDrawColor($drawColor['r'], $drawColor['g'], $drawColor['b']);
}
$lineWidth = $tagProperties['LINEWIDTH'];
if ($lineWidth != '') {
$currentLW = $pdf->LineWidth;
$pdf->SetLineWidth((double) $lineWidth);
}
$x1 = $this->mathEval($tagProperties['LEFT']);
$x2 = $this->mathEval($tagProperties['RIGHT']);
$y1 = $this->mathEval($tagProperties['TOP']);
$y2 = $this->mathEval($tagProperties['TOP']);
$pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2);
$y1 = $this->mathEval($tagProperties['BOTTOM']);
$y2 = $y1;
$pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2);
//$x1 = $this->mathEval($tagProperties['LEFT']);
$x2 = $x1;
$y1 = $this->mathEval($tagProperties['TOP']);
$y2 = $this->mathEval($tagProperties['BOTTOM']);
$pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2);
$x1 = $this->mathEval($tagProperties['RIGHT']);
$x2 = $x1;
//$y1 = $this->mathEval($tagProperties['TOP']);
//$y2 = $this->mathEval($tagProperties['BOTTOM']);
$pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2);
if ($lineWidth != '') {
$pdf->SetLineWidth($currentLW);
}
}
示例7: instance
public static function instance()
{
if (!$instance) {
self::$instance = new Pdf();
}
return self::$instance;
}
示例8: __construct
public function __construct($tagProperties)
{
$pdf = Pdf::singleton();
$x = $tagProperties['LEFT'];
$y = $tagProperties['TOP'];
$w = $tagProperties['WIDTH'];
$h = $tagProperties['HEIGHT'];
$r = $tagProperties['RADIUS'];
$style = $tagProperties['STYLE'];
$angle = $tagProperties['ANGLE'];
$lineColor = $tagProperties['LINECOLOR'];
if ($lineColor != '') {
$drawColor = Xml2Pdf::convertColor($lineColor);
$pdf->SetDrawColor($drawColor['r'], $drawColor['g'], $drawColor['b']);
}
$lineWidth = $tagProperties['LINEWIDTH'];
if ($lineWidth != '') {
$current = $pdf->LineWidth;
$pdf->SetLineWidth((double) $lineWidth);
}
$pdf->RoundedRect($x, $y, $w, $h, $r, $angle, $style);
if ($lineWidth != '') {
$pdf->SetLineWidth($current);
}
}
示例9: __construct
/**
* Constructor.
*
* @param array $tagProperties tag properties
* @return void
*/
public function __construct($tagProperties)
{
$pdf = Pdf::singleton();
if (isset($tagProperties['FILE'])) {
$this->_styleSheet = $tagProperties['FILE'];
$this->_parseStyleSheet();
$pdf->addStyles($this->_styleTags);
}
}
示例10: testEmbedHtmlImage
function testEmbedHtmlImage()
{
// NOTE: to embed images, use <img src=""> tag but specify a path to an existing file
$model = new \Core3\Model\Spreadsheet();
$model->defineColumns(array('id', 'name'));
$model->addRow(array('1', 'kalle'));
$model->addRow(array('2', 'olle'));
$imgFile = tempnam('/tmp', 'embedHtmlImage');
$this->createJpeg($imgFile);
$writer = new Pdf();
$writer->setStartHtmlBlock('<img src="' . $imgFile . '"/><br/>');
$writer->setEndHtmlBlock('<h2>GOODBYE</h2>');
$data = $writer->render($model);
unlink($imgFile);
$reader = new \Core3\Reader\BinaryData\Document();
$this->assertEquals(true, $reader->isRecognized($data));
$this->assertEquals(true, $reader->isPdfData($data));
}
示例11: print_brgy_leaders
public function print_brgy_leaders($voter_data = array(), $data = array())
{
$this->load->library('pdf');
$pdf = new Pdf('L', 'mm', 'LETTER', true, 'UTF-8', false);
$pdf->SetTitle('My Title');
$pdf->SetHeaderMargin(30);
$pdf->SetTopMargin(20);
$pdf->setFooterMargin(10);
$pdf->SetAutoPageBreak(true, 15);
$pdf->SetAuthor('Author');
$pdf->AddPage('L', 'LEGAL');
$pdf->setY(30);
$html = '';
$html .= '<div style="text-align: center;"><b>Brgy Leaders</b> for<br/><b>' . $data['brgy'] . '</b></div>';
$html .= '<br/>';
$html .= '<br/>';
$html .= '<table style="border: 1px solid #000;border-collapse: collapse;" border="1" cellspacing="0" cellpadding="1">';
$html .= '<thead>';
$html .= '<tr style="background-color: #a8a8a8;">';
$html .= '<th align="center" width="5%"></th>';
$html .= '<th align="center" width="45%"><b>Voter\'s Name</b></th>';
$html .= '<th align="center" width="30%"><b>Precinct No</b></th>';
$html .= '<th align="center" width="20%"><b>Type</b></th>';
$html .= '</tr>';
$html .= '</thead>';
if (count($voter_data) > 0) {
$x = 1;
foreach ($voter_data as $type => $val) {
for ($ctr = 0; $ctr < count($val); $ctr++) {
$html .= '<tr nobr="true">';
$html .= '<td align="center" width="5%">' . $x . '.</td>';
$html .= '<td width="45%"> ' . $val[$ctr]['full_name'] . '</td>';
$html .= '<td width="30%"> ' . $val[$ctr]['precinct_no'] . '</td>';
$html .= '<td width="20%"> ' . $val[$ctr]['type'] . '</td>';
$html .= '</tr>';
$x++;
}
}
} else {
$html .= '<tr>';
$html .= '<td align="center" width="100%">No record found..</td>';
$html .= '</tr>';
}
$html .= '</table>';
$pdf->writeHTML($html, true, false, false, false, '');
$pdf->Output('brgy_leaders_report.pdf', 'I');
}
示例12: renderPdf
/**
*
*
*/
public function renderPdf(Student $student)
{
$html = view($this->getHtmlView())->with('responses', $this->responses)->with('student', $student)->render();
if (isset($_GET['html'])) {
return $html;
}
$pdfOptions = ['margin-top' => 20, 'margin-bottom' => 10, 'margin-left' => 10, 'margin-right' => 10, 'zoom' => config('iep.html_renderer_zoom')];
if ($this->headerViewEixsts()) {
$header = view($this->getHeaderView())->with('responses', $this->responses)->with('student', $student)->render();
$pdfOptions['header-html'] = $header;
$pdfOptions['header-spacing'] = 2;
}
$pdf = new Pdf($pdfOptions);
$pdf->addPage($html);
$savePath = $this->getSavePath($student->lastfirst);
if (!$pdf->saveAs($savePath)) {
throw new Exception($pdf->getError());
}
return $savePath;
}
示例13: __construct
/**
* Constructor.
*
* @param $tagProperties tag attributes
* @return void
*/
public function __construct($tagProperties)
{
$pdf = Pdf::singleton();
if (isset($tagProperties['TITLE'])) {
$pdf->setTitle($tagProperties['TITLE']);
}
if (isset($tagProperties['SUBJECT'])) {
$pdf->setSubject($tagProperties['SUBJECT']);
}
if (isset($tagProperties['CREATOR'])) {
$pdf->setCreator($tagProperties['CREATOR']);
}
}
示例14: generarListadogeneneral
public function generarListadogeneneral()
{
$nombre = $this->input->get("nombre") != '' ? "LIKE '%" . $this->input->get("nombre") . "%'" : 'LIKE "%"';
$apellido = $this->input->get("apellido") != '' ? "LIKE '%" . $this->input->get("apellido") . "%'" : 'LIKE "%"';
$pdf = new Pdf('l', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetSubject('Tutorial TCPDF');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// $pdf->SetHeaderData(PDF_HEADER_LOGO,PDF_HEADER_LOGO_WIDTH,PDF_HEADER_TITLE,PDF_HEADER_STRING,array(0,64,255),array(0,64, 128));
$pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128));
// datos por defecto de cabecera, se pueden modificar en el archivo tcpdf_config.php de libraries/config
// $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH,'Listado General',PDF_HEADER_STRING,array(0,64,255), array(0,64,128));
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetPageOrientation('p');
// se pueden modificar en el archivo tcpdf_config.php de libraries/config
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// se pueden modificar en el archivo tcpdf_config.php de libraries/config
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// se pueden modificar en el archivo tcpdf_config.php de libraries/config
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//relación utilizada para ajustar la conversión de los píxeles
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// establecer el modo de fuente por defecto
$pdf->setFontSubsetting(true);
$pdf->SetFont('times', '', 9, '', true);
$pdf->AddPage();
$html = null;
$nombre_archivo = null;
// Establecemos el contenido para imprimir
$resultado = $this->ReporteGeneral_model->getlistadogeneral($nombre, $apellido);
if ($resultado) {
$html = '';
$html .= "<style type=text/css>";
$html .= "th{color: #fff; font-weight: bold; background-color: #0B615E; align=center}";
$html .= "td{background-color: #fff; color: #222; align=center}";
$html .= "</style>";
$html .= "<h2>Listado General de las Personas con Permisos</h2>";
$html .= "<table width='100%' border='1' cellpadding='0' cellspacing='0' >";
$html .= "<tr>\r\n <th><em>Fecha del Permiso</em></th>\r\n <th><em>Cédula</em></th>\r\n <th><em>Nombres</em></th>\r\n <th><em>Cantidad de salidas</em></th>\r\n <th><em>Departamento</em></th>\r\n <th><em>Motivo</em></th>\r\n </tr>";
foreach ($resultado as $fila) {
$html .= '<tr>
<td>' . mb_convert_case($fila["fechaautorizacion"], MB_CASE_TITLE, "UTF-8") . '</td>
<td>' . mb_convert_case($fila["cedula"], MB_CASE_TITLE, "UTF-8") . '</td>
<td>' . mb_convert_case($fila["nombre"], MB_CASE_TITLE, "UTF-8") . ' ' . mb_convert_case($fila["apellido"], MB_CASE_TITLE, "UTF-8") . '</td>
<td>' . mb_convert_case($fila["contsalida"], MB_CASE_TITLE, "UTF-8") . '</td>
<td>' . mb_convert_case($fila["departamento"], MB_CASE_TITLE, "UTF-8") . '</td>
<td>' . mb_convert_case($fila["motivo"], MB_CASE_TITLE, "UTF-8") . '</td>
</tr>
<hr>';
}
$html .= "</table>";
$cantidad = count($resultado);
if ($cantidad > 1) {
$html .= "<h4>Actualmente: " . count($resultado) . " empleados con permisos</h4>";
} else {
$html .= "<h4>Actualmente: " . count($resultado) . " empleados con permisos</h4>";
}
$nombre_archivo = utf8_decode("Listado General.pdf");
} else {
$html = '';
$html .= "<style type=text/css>";
$html .= "th{color: #fff; font-weight: bold; background-color: #AAC7E3}";
$html .= "td{background-color: #fff; color: #222}";
$html .= "</style>";
$html .= "<h4>Listado General de las Personas con Permisos</h4>";
$html .= "<table width='100%'>";
$html .= "<tr><th>No hay empleados de permiso con las características indicadas</th></tr>";
$html .= "</table>";
$nombre_archivo = utf8_decode("Listado General " . $nombre . ".pdf");
}
$pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = 'C', $autopadding = true);
$pdf->Output($nombre_archivo, 'I');
}
示例15: postProcess
//.........这里部分代码省略.........
if ($mask->getCorrect() === '1' && !$foundInStudentsAnswer) {
$allcorrect = false;
break;
} elseif ($mask->getCorrect() === '0' && $foundInStudentsAnswer) {
$allcorrect = false;
break;
}
}
}
if ($allcorrect) {
$points = $pro->getExercise()->getMaxPoints();
}
// save the marking
#region Form to PDF
if ($pro->getMarking() === null) {
$raw = $pro->getRawSubmission();
$exerciseName = '';
if ($raw !== null) {
$exerciseName = $raw->getExerciseName();
}
$answer = "";
if ($forms->getType() == 0) {
$answer = $formdata->getChoices()[0]->getText();
}
if ($forms->getType() == 1) {
$answer = $this->ChoiceIdToText($formdata->getChoices()[0]->getText(), $forms->getChoices());
}
if ($forms->getType() == 2) {
foreach ($formdata->getChoices() as $chosen) {
$answer .= $this->ChoiceIdToText($chosen->getText(), $forms->getChoices()) . '<br>';
}
}
$answer2 = "";
foreach ($forms->getChoices() as $chosen) {
if ($chosen->getCorrect() === '1') {
$answer2 .= $chosen->getText() . '<br>';
}
}
$Text = "<h1>AUFGABE {$exerciseName}</h1>" . "<hr>";
if ($forms->getTask() !== null && trim($forms->getTask()) != '') {
$Text .= "<p>" . "<h2>Aufgabenstellung:</h2>" . $forms->getTask() . "</p>";
}
$Text .= "<p>" . "<h2>Antwort:</h2>" . "<span style=\"color: " . ($points === 0 ? 'red' : 'black') . "\">" . $answer . "</span></p>";
if ($points === 0) {
$Text .= "<p>" . "<h2>Lösung:</h2><span style=\"color: green\">" . $answer2 . "</span></p>";
}
if ($forms->getSolution() !== null && trim($forms->getSolution()) != '') {
$Text .= "<p>" . "<h2>Lösungsbegründung:</h2>" . $forms->getSolution() . "</p>";
}
$Text .= "<p style=\"text-align: center;\">" . "<h2><span style=\"color: red\">{$points}P</span></h2>" . "</p>";
$pdf = Pdf::createPdf($Text);
//echo Pdf::encodePdf($pdf);return;
$result = Request::routeRequest('POST', '/pdf', array(), Pdf::encodePdf($pdf), $this->_pdf, 'pdf');
// checks the correctness of the query
if ($result['status'] >= 200 && $result['status'] <= 299) {
$pdf = File::decodeFile($result['content']);
$pdf->setDisplayName($exerciseName . '.pdf');
$pdf->setTimeStamp($timestamp);
$pdf->setBody(null);
$submission = $pro->getSubmission();
if ($submission === null) {
$submission = $pro->getRawSubmission();
}
$studentId = $pro->getRawSubmission() !== null ? $pro->getRawSubmission()->getStudentId() : null;
if ($studentId === null) {
$studentId = $pro->getSubmission() !== null ? $pro->getSubmission()->getStudentId() : null;
}
$marking = Marking::createMarking(null, $studentId, null, null, null, null, 3, $points, $submission->getDate() !== null ? $submission->getDate() : time());
if (is_object($submission)) {
$marking->setSubmission(clone $submission);
}
$marking->setFile($pdf);
$pro->setMarking($marking);
} else {
$res[] = null;
$this->app->response->setStatus(409);
continue;
}
}
#endregion
$rawSubmission = $pro->getRawSubmission();
$rawFile = $rawSubmission->getFile();
$rawFile->setBody(Form::encodeForm($formdata), true);
$rawSubmission->setFile($rawFile);
$rawSubmission->setExerciseId($eid);
$pro->setRawSubmission($rawSubmission);
$res[] = $pro;
continue;
}
}
}
$this->app->response->setStatus(409);
$res[] = null;
}
if (!$arr && count($res) == 1) {
$this->app->response->setBody(Process::encodeProcess($res[0]));
} else {
$this->app->response->setBody(Process::encodeProcess($res));
}
}