I baked in some support into image_cache.cls.php (it was actually
fairly easy).
I have uploaded a DIFF patch file based on the latest trunk checkout
as of Feb 10, 2009 (r209). The patch was uploaded the files section of
the google group: http://groups.google.com/group/dompdf/web/data_uri_patch_r209.patch
I have also included the DIFF at the end of this post.
I don't know how many people will get use out of this but I figured
I'd contribute back just in case anyone else did.
--Daniel Cousineau
--http://www.toosweettobesour.com/
Index: include/image_cache.cls.php
===================================================================
--- include/image_cache.cls.php (revision 209)
+++ include/image_cache.cls.php (working copy)
@@ -94,7 +94,19 @@
$remote = ($proto != "" && $proto !== "file://");
$remote = $remote || ($parsed_url['protocol'] != "");
- if ( !DOMPDF_ENABLE_REMOTE && $remote ) {
+ //Data URI
+ $matches = array();
+ if( preg_match('#data:(?<mime>[^/]+\/[^;]+);base64,(?
<data>.*)#i', $url, $matches) ) {
+ $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_");
+
+ file_put_contents($resolved_url,
base64_decode($matches['data']));
+
+ list($category, $ext) = explode('/', $matches['mime'], 2);
+
+ //debugpng
+ if ($DEBUGPNG) $full_url_dbg = '(data uri)';
+ }
+ else if ( !DOMPDF_ENABLE_REMOTE && $remote ) {
$resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
$ext = "png";