From: Stéphane Jacob Date: Mon, 10 Jan 2011 20:07:47 +0000 (+0100) Subject: Fixes contact pdf export with pictures (Closes #1139). X-Git-Tag: xorg/1.1.0~198 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1415e9ca43429d2f2c1deb3a562a01756a5f0ea0;p=platal.git Fixes contact pdf export with pictures (Closes #1139). Signed-off-by: Stéphane Jacob --- diff --git a/modules/carnet/contacts.pdf.inc.php b/modules/carnet/contacts.pdf.inc.php index fa284fc..ed79ee9 100644 --- a/modules/carnet/contacts.pdf.inc.php +++ b/modules/carnet/contacts.pdf.inc.php @@ -265,23 +265,27 @@ class ContactsPDF extends FPDF if ($wp) { $photo = $profile->getPhoto(false, true); if ($photo) { - $old2 = clone $self; - $width = $photo->width() * 20 / $photo->height(); - $_x = $self->getX(); - $_y = $self->getY(); - $self->Cell(0, 20, '', '', 0, '', 1); - error_reporting(0); - $self->Image($photo->path(), $_x, $_y, $width, 20, $photo->mimeType()); - error_reporting($self->report); - - if ($self->error) { - $self = clone $old2; - } else { - $self->setX($_x); - $self->Cell($width, 20, '', "T"); - $h = 20 / $self->wordwrap($nom, 90 - $width); - $self->MultiCell(0, $h, $nom, 'T', 'C'); - $ok = true; + list(, $type) = explode('/', $photo->mimeType()); + $type = ($type == 'jpeg') ? 'jpg' : $type; + if (method_exists($self, '_parse' . $type)) { + $old2 = clone $self; + $width = $photo->width() * 20 / $photo->height(); + $_x = $self->getX(); + $_y = $self->getY(); + $self->Cell(0, 20, '', '', 0, '', 1); + error_reporting(0); + $self->Image($photo->path(), $_x, $_y, $width, 20, $type); + error_reporting($self->report); + + if ($self->error) { + $self = clone $old2; + } else { + $self->setX($_x); + $self->Cell($width, 20, '', "T"); + $h = 20 / $self->wordwrap($nom, 90 - $width); + $self->MultiCell(0, $h, $nom, 'T', 'C'); + $ok = true; + } } } }