code: function writeImageToPDF(x, y, w, h, info, index, images, rotation) {
      var dims = determineWidthAndHeight.call(this, w, h, info),
          coord = this.internal.getCoordinateString,
          vcoord = this.internal.getVerticalCoordinateString;
      w = dims[0];
      h = dims[1];
      images[index] = info;
  
      if (rotation) {
        rotation *= Math.PI / 180;
        var c = Math.cos(rotation);
        var s = Math.sin(rotation); //like in pdf Reference do it 4 digits instead of 2
  
        var f4 = function f4(number) {
          return number.toFixed(4);
        };
  
        var rotationTransformationMatrix = [f4(c), f4(s), f4(s * -1), f4(c), 0, 0, 'cm'];
      }
  
      this.internal.write('q'); //Save graphics state
  
      if (rotation) {
        this.internal.write([1, '0', '0', 1, coord(x), vcoord(y + h), 'cm'].join(' ')); //Translate
  
        this.internal.write(rotationTransformationMatrix.join(' ')); //Rotate
  
        this.internal.write([coord(w), '0', '0', coord(h), '0', '0', 'cm'].join(' ')); //Scale
      } else {
        this.internal.write([coord(w), '0', '0', coord(h), coord(x), vcoord(y + h), 'cm'].join(' ')); //Translate and Scale
      }
  
      this.internal.write('/I' + info['i'] + ' Do'); //Paint Image
  
      this.internal.write('Q'); //Restore graphics state
    }
docs: Image functionality ported from pdf.js