public function runProcessStep($dokument) { $file = $dokument->getLatestRevision()->getFile(); $extension = array_pop(explode(".", $file->getExportFilename())); #$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename()); // Print Metainfo for PDFs if (strtolower($extension) == "pdf") { try { $fpdf = new FPDI(); $pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename()); $fpdf->SetMargins(0, 0, 0); $fpdf->SetFont('Courier', '', 8); $fpdf->SetTextColor(0, 0, 0); $documentSize = null; for ($i = 0; $i < $pagecount; $i++) { $string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")"; $fpdf->AddPage(); $tpl = $fpdf->importPage($i + 1); $size = $fpdf->getTemplateSize($tpl); // First Page defines documentSize if ($documentSize === null) { $documentSize = $size; } // Center Template on Document $fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true); $fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string); } $this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S")); } catch (Exception $e) { $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension); } } else { $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension); } }
function GetStringWidth($s) { if ($this->CurrentFont['type'] == 'Type0') { return $this->GetSJISStringWidth($s); } else { return parent::GetStringWidth($s); } }
<?php if (isset($_POST['nombre'])) { $nombre = $_POST['nombre']; $myfile = fopen("data/diplomas.txt", "a"); date_default_timezone_set('America/Santiago'); fwrite($myfile, $nombre . "\t" . date('d/m/Y H:i:s', time()) . "\n"); fclose($myfile); $nombre = iconv('UTF-8', 'windows-1252', html_entity_decode($nombre)); // http://www.setasign.com/products/fpdi/demos/simple-demo/ require_once 'include/fpdf17/fpdf.php'; require_once 'include/FPDI-1.5.4/fpdi.php'; $pdf = new FPDI(); $pdf->setSourceFile("media/felicitaciones.pdf"); $tplIdx = $pdf->importPage(1); $size = $pdf->getTemplateSize($tplIdx); $pdf->AddPage('L', array($size['w'], $size['h'])); $pdf->useTemplate($tplIdx); //$pdf->useTemplate($tplIdx, 10, 10, 100); $pdf->SetFont('Helvetica', 'B', 30); $pdf->SetTextColor(0, 0, 0); $mid_x = $size['w'] / 2; $str_w = $pdf->GetStringWidth($nombre) / 2; $pos_x = $mid_x - $str_w; $pdf->SetXY($pos_x, 65); $pdf->Write(0, $nombre); $pdf->Output(); } else { header("Location: index.php"); die; }
$pdf->WriteRight(11.5, 0, number_format($personagem->getPesoTotal(), 2, ',', '.')); $pdf->SetXY(86.5, 249); $pdf->WriteRight(4, 0, $personagem->getPontoAtributo()); $pdf->SetXY(86.5, 258.5); $pdf->WriteRight(4, 0, $personagem->getPontoVantagem()); $pdf->SetXY(86.5, 263); $pdf->WriteRight(4, 0, $personagem->getPontoDesvantagem()); $pdf->SetXY(86.5, 267.5); $pdf->WriteRight(4, 0, $personagem->getPontoPericia()); $pdf->SetFontSize(9); $y = 198.5; // Largura 80 $palavras = explode(' ', trim($personagem->getDescricao())); $linha = ''; foreach ($palavras as $palavra) { $largura = $pdf->GetStringWidth($linha . ' ' . $palavra); if ($largura > 80) { $pdf->SetXY(12, $y); $pdf->Write(0, $linha); $y += 4.6; $linha = $palavra; } else { if ($linha == '') { $linha = $palavra; } else { $linha .= ' ' . $palavra; } } } if ($linha != '') { $pdf->SetXY(12, $y);