return this.interpretHelper(new Parser(new Lexer(obj), true));
         },
         interpretHelper: function(parser) {
+            this.gfx.beginDrawing();
+
             var args = [ ];
             var obj;
             while (!((obj = parser.getObj()).isEOF())) {
                     args.push(obj);
                 }
             }
+
+            this.gfx.endDrawing();
         },
         typeCheck: function(params, args) {
             if (params.length != args.length)
     }
 
     constructor.prototype = {
+        beginDrawing: function () {
+        },
+        endDrawing: function () {
+        },
+
         // Graphics state
         setLineWidth: function(width) {
             this.printdentln(width +" w");
 })();
 
 var CanvasGraphics = (function() {
-    function constructor(canvasCtx, hdpi, vdpi, pageBox) {
+    function constructor(canvasCtx) {
         this.ctx = canvasCtx;
         this.current = new CanvasExtraState();
         this.stateStack = [ ];
     }
 
     constructor.prototype = {
+        beginDrawing: function () {
+            this.ctx.save();
+            this.ctx.scale(1, -1);
+            this.ctx.translate(0, -this.ctx.canvas.height);
+        },
+        endDrawing: function () {
+            this.ctx.restore();
+        },
+
         // Graphics state
         setLineWidth: function(width) {
             this.ctx.lineWidth = width;
             this.current.lineY = y;
         },
         showText: function(text) {
+            this.ctx.save();
+            this.ctx.translate(0, 2 * this.current.lineY);
+            this.ctx.scale(1, -1);
+
             this.ctx.fillText(text, this.current.lineX, this.current.lineY);
+
+            this.ctx.restore();
         },
 
         // Type3 fonts
 
     pageDisplay.value = number;
 
     var ctx = canvas.getContext("2d");
-    ctx.save();
     ctx.clearRect(0, 0, canvas.width, canvas.height);
-    var gfx = new CanvasGraphics(ctx, 96.0, 96.0, null);
+    var gfx = new CanvasGraphics(ctx);
     var interp = new Interpreter(null, page.res, null, gfx);
     interp.interpretHelper(new MockParser(page.objs));
-    ctx.restore();
 }
 
 function nextPage() {