Skip to content
Snippets Groups Projects
Commit 1aee8639 authored by Ron Shimshock's avatar Ron Shimshock Committed by Klaus Purer
Browse files

fix(dompdf): Relative images are not supported on DomPDF v0.8.0+ (#3172857 by...

fix(dompdf): Relative images are not supported on DomPDF v0.8.0+ (#3172857 by Eduardo Morales Alberti, ron_s, klausi, ShaneOnABike, 4kant)
parent 962c6929
No related branches found
No related tags found
No related merge requests found
......@@ -229,11 +229,35 @@ function commerce_billy_pdf_commerce_order_view($order, $view_mode) {
$logo_path = DRUPAL_ROOT . '/' . $logo_path;
}
$order->content['invoice_logo'] = array(
'#value' => $logo_path,
'#value' => _commerce_billy_pdf_base64_image($logo_path),
);
}
}
/**
* Convert image path into Base64 image.
*
* @param string $image_path
* Valid image path to convert.
*
* @return string
* Base64 image.
*/
function _commerce_billy_pdf_base64_image($image_path) {
// Check if image exists in local file system.
if (file_exists($image_path)) {
$image_data = base64_encode(file_get_contents($image_path));
$mime_type = mime_content_type($image_path);
// Image source format: "data:{mime};base64,{data};"
return 'data:' . $mime_type . ';base64,' . $image_data;
}
// If the file cannot be found, post a watchdog message and display no logo.
watchdog('commerce_billy_pdf', 'Invoice logo does not exist or cannot be found: %path',
array('%path' => $image_path), WATCHDOG_ERROR);
return '';
}
/**
* Transforms HTML to PDF and outputs it to the browser.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment