Printing with scale

In our print code we allow the user to select the scale and have based the code off your printing example. What happens is when the scale isn’t 1.0 the tiling doesn’t work properly. Modifying your print example to do scale of 1.1 shows the problem. I also tried changing the boundswidth and boundsheight multiplying by 1.1 but that doesn’t help. Here is what I changed in printing.html and this happens with both 1.5 and 1.6.

  var imgDiv = document.getElementById('myImages');
  imgDiv.innerHTML = ''; // clear out the old images, if any
  var db = myDiagram.documentBounds.copy();
  var boundswidth = db.width * 1.1;
  var boundsheight = db.height * 1.1;
  var imgWidth = width;
  var imgHeight = height;
  var p = db.position.copy();
  for (var i = 0; i < boundsheight; i += imgHeight) {
    for (var j = 0; j < boundswidth; j += imgWidth) {
      img = myDiagram.makeImage({
        scale: 1.1,
        position: new go.Point(p.x + j, p.y + i),
        size: new go.Size(imgWidth, imgHeight)
      });
      // Append the new HTMLImageElement to the #myImages div
      img.className = 'images';
      imgDiv.appendChild(img);
      imgDiv.appendChild(document.createElement('br'));
    }
  }
}

Am I doing something wrong or could this be a bug?

You probably need to do something like:

  var scale = 1.5;

  var imgDiv = document.getElementById('myImages');
  imgDiv.innerHTML = ''; // clear out the old images, if any
  var db = myDiagram.documentBounds.copy();
  var boundswidth = db.width * scale;
  var boundsheight = db.height * scale;
  var imgWidth = width;
  var imgHeight = height;
  var p = db.position.copy();
  for (var i = 0; i < boundsheight; i += imgHeight) {
    for (var j = 0; j < boundswidth; j += imgWidth) {
      img = myDiagram.makeImage({
        scale: scale,
        position: new go.Point(p.x + j/scale, p.y + i/scale),
        size: new go.Size(imgWidth, imgHeight)
      });
      // Append the new HTMLImageElement to the #myImages div
      img.className = 'images';
      imgDiv.appendChild(img);
      imgDiv.appendChild(document.createElement('br'));
    }
  }
}

Note the:

        position: new go.Point(p.x + j/scale, p.y + i/scale),

There may be other considerations, but they’d be mathematical and not related to GoJS.

Here’s an example: http://codepen.io/simonsarris/pen/pywXEo

position is what I was missing. Thx.