#100 Add SVG support for image and bgimage elements.

This commit is contained in:
David Balch 2017-04-24 16:17:41 +01:00 committed by Mark Nelson
parent 408da87cb3
commit d2fc041038
2 changed files with 13 additions and 2 deletions

View file

@ -98,7 +98,12 @@ class element extends \customcertelement_image\element {
$file->copy_content_to($location);
// Set the image to the size of the PDF page.
$pdf->Image($location, 0, 0, $pdf->getPageWidth(), $pdf->getPageHeight());
$mimetype = $file->get_mimetype();
if ($mimetype == 'image/svg+xml') {
$pdf->ImageSVG($location, 0, 0, $pdf->getPageWidth(), $pdf->getPageHeight());
} else {
$pdf->Image($location, 0, 0, $pdf->getPageWidth(), $pdf->getPageHeight());
}
}
}

View file

@ -173,7 +173,13 @@ class element extends \mod_customcert\element {
if ($file = $fs->get_file_by_hash($imageinfo->pathnamehash)) {
$location = make_request_directory() . '/target';
$file->copy_content_to($location);
$pdf->Image($location, $this->element->posx, $this->element->posy, $imageinfo->width, $imageinfo->height);
$mimetype = $file->get_mimetype();
if ($mimetype == 'image/svg+xml') {
$pdf->ImageSVG($location, $this->element->posx, $this->element->posy, $imageinfo->width, $imageinfo->height);
} else {
$pdf->Image($location, $this->element->posx, $this->element->posy, $imageinfo->width, $imageinfo->height);
}
}
}