var cs = this.getFillColorSpace();
 
       if (cs.name == 'Pattern') {
-        var patternName = arguments[0];
-        this.setFillPattern(patternName);
+        var length = arguments.length;
+        var base = cs.base;
+        if (base) {
+          var baseComps = base.numComps;
+
+          if (baseComps != length - 1)
+            error("invalid base color for pattern colorspace");
+
+          var color = [];
+          for (var i = 0; i < baseComps; ++i)
+            color.push(arguments[i]);
+
+          color = base.getRgb(color);
+        }
+        var patternName = arguments[length - 1];
+        this.setFillPattern(patternName, base, color);
       } else {
         // TODO real impl
         this.setFillColor.apply(this, arguments);
       }
     },
-    setFillPattern: function(patternName) {
+    setFillPattern: function(patternName, baseCS, color) {
       if (!IsName(patternName))
         error("Bad args to getPattern");
 
       var patternFn = types[typeNum];
       if (!patternFn)
         error("Unhandled pattern type");
-      patternFn.call(this, pattern, dict);
+      patternFn.call(this, pattern, dict, baseCS, color);
     },
     setShadingPattern: function(pattern, dict) {
       var matrix = dict.get("Matrix");
       this.ctx.fillRect(0,0,0,0);
       this.transform.apply(this, inv);
     },
-    setTilingPattern: function(pattern, dict) {
+    setTilingPattern: function(pattern, dict, baseCS, color) {
       function multiply(m, tm) {
         var a = m[0] * tm[0] + m[1] * tm[2];
         var b = m[0] * tm[1] + m[1] * tm[3];
       this.save();
       var ctx = this.ctx;
 
-      var paintType = dict.get('PaintType');
-      switch (paintType) {
-      case PAINT_TYPE_COLORED:
-        // should go to default for color space
-        ctx.fillStyle = this.makeCssRgb(1, 1, 1);
-        ctx.strokeStyle = this.makeCssRgb(0, 0, 0);
-        break;
-      case PAINT_TYPE_UNCOLORED:
-      default:
-        error('Unsupported paint type');
-      }
 
       TODO('TilingType');
 
       var savedCtx = ctx;
       this.ctx = tmpCtx;
 
+      var paintType = dict.get('PaintType');
+      switch (paintType) {
+      case PAINT_TYPE_COLORED:
+        // should go to default for color space
+        tmpCtx.fillStyle = this.makeCssRgb(1, 1, 1);
+        tmpCtx.strokeStyle = this.makeCssRgb(0, 0, 0);
+        break;
+      case PAINT_TYPE_UNCOLORED:
+        tmpCtx.fillStyle = this.makeCssRgb.apply(this, baseCS.getRgb(color));
+        tmpCtx.strokeStyle = this.makeCssRgb.apply(this, baseCS.getRgb(color));
+        break;
+      default:
+        error('Unsupported paint type');
+      }
+
       // normalize transform matrix so each step
       // takes up the entire tmpCanvas (need to remove white borders)
       if (matrix[1] === 0 && matrix[2] === 0) {
 
       var typeNum = shading.get('ShadingType');
       var shadingFn = types[typeNum];
+
+      // Most likely we will not implement other types of shading
+      // unless the browser supports them
       if (!shadingFn)
-        error("Unknown or NYI type of shading '"+ typeNum +"'");
+        TODO("Unknown or NYI type of shading '"+ typeNum +"'");
+
       return shadingFn.call(this, shading, cs);
                 },
     getAxialShading: function(sh, cs) {
           return new DeviceCmykCS();
         break;
       case 'Pattern':
-        return new PatternCS();
+        var baseCS = cs[1];
+        if (baseCS)
+          baseCS = ColorSpace.parse(baseCS, xref, res);
+        return new PatternCS(baseCS);
         break;
       case 'Indexed':
         var base = ColorSpace.parse(cs[1], xref, res);
 })();
 
 var PatternCS = (function() {
-  function constructor() {
+  function constructor(baseCS) {
     this.name = 'Pattern';
+    this.base = baseCS;
   }
   constructor.prototype = {};