#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,9 +98,14 @@ class element extends \customcertelement_image\element {
$file->copy_content_to($location); $file->copy_content_to($location);
// Set the image to the size of the PDF page. // Set the image to the size of the PDF page.
$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()); $pdf->Image($location, 0, 0, $pdf->getPageWidth(), $pdf->getPageHeight());
} }
} }
}
/** /**
* Render the element in html. * Render the element in html.

View file

@ -173,9 +173,15 @@ class element extends \mod_customcert\element {
if ($file = $fs->get_file_by_hash($imageinfo->pathnamehash)) { if ($file = $fs->get_file_by_hash($imageinfo->pathnamehash)) {
$location = make_request_directory() . '/target'; $location = make_request_directory() . '/target';
$file->copy_content_to($location); $file->copy_content_to($location);
$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); $pdf->Image($location, $this->element->posx, $this->element->posy, $imageinfo->width, $imageinfo->height);
} }
} }
}
/** /**
* Render the element in html. * Render the element in html.