makeImageData of diagram with background


I would like to download an image of my diagram.
It works so far but by adding a background to my image, this one doesnt have the same size as my diagram
I tried to use different size, scale ect using makeImageData

Is the background image something that you are showing to the user in the diagram? If so, how are you doing that?

Hi, no it is not. The diagram has no background (transparency)
Here is the part where I add the background

let img = diagram.makeImageData({
          background: '#ede0dd'

Which version of GoJS are you actually using? I thought we had fixed a bug like that, but it was a while ago.

I am using 2.0.8 version, should I update it ?

Yes, see if it is already fixed.

Well, it is still not working.
Should I add something as scale, size ?

Are you sure you are using version 2.1.20? Or another recent version? Evaluate “go.Diagram.version” in the debugger.

I just tried this in the Minimal sample app:

  function test() {
    var img = myDiagram.makeImage({
      background: '#ede0dd'

and it did exactly as I think you would expect.

Yes I am sure I am using the version 2.1.20.
This is the result

If I change the zoom i have something like this

It seems to work correctly with size only if the zoom > 80%

That call is only supposed to return an image of what is in the viewport.
Specify other options such as scale to get the whole diagram.
Please read, or if you can use SVG,

I still don’t know exactly what you want, and I know it’s hard to explain. Here’s another example:

    var vb = myDiagram.viewportBounds;
    var s = myDiagram.scale;
    var img = myDiagram.makeImage({
      background: '#ede0dd',
      scale: s,
      position: vb.position,
      size: new go.Size(vb.width*s, vb.height*s)