本文整理汇总了PHP中FPDI::GetStringWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::GetStringWidth方法的具体用法?PHP FPDI::GetStringWidth怎么用?PHP FPDI::GetStringWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::GetStringWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runProcessStep
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);
}
}
示例2: GetStringWidth
function GetStringWidth($s)
{
if ($this->CurrentFont['type'] == 'Type0') {
return $this->GetSJISStringWidth($s);
} else {
return parent::GetStringWidth($s);
}
}
示例3: fopen
<?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;
}
示例4: explode
$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);