Its possible make a diagram image as in pdf , i tryed this manner but not showing the image and pdf was format error

generateImages (width:any, height:any) {
console.log(width)
console.log(height)

  // sanitize input
  width = parseInt(width);
  height = parseInt(height);
  if (isNaN(width)) width = 100;
  if (isNaN(height)) height = 100;
  // Give a minimum size of 50x50
  width = Math.max(width, 50);
  height = Math.max(height, 50);
  var imgDiv = document.getElementById('myImages');
  console.log(imgDiv)
  imgDiv.innerHTML = ''; // clear out the old images, if any
  var db = this.myDiagram.documentBounds.copy();
  var boundswidth = db.width;
  var boundsheight = db.height;
  var imgWidth = width;
  var imgHeight = height;
  var p = db.position.copy();
  //making images
  for (var i = 0; i< boundsheight; i += imgHeight) {
    var img:any
    for (var j = 0; j < boundswidth; j += imgWidth) {
       img= this.myDiagram.makeImage({
        scale: 1, 
          type: "image/jpeg",
          background: "AntiqueWhite",
        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'));
    }
              this.saveAsFile(img);
  }      
}

destroyClickedElement(event:any){
document.body.removeChild(event.target);
}
saveAsFile(val:any)
{
var pdf_image = val
var textToSaveAsBlob = new Blob([pdf_image], {type:“image/jpeg”});
var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
// var fileNameToSaveAs = document.getElementById(“inputFileNameToSaveAs”).value;

var downloadLink = document.createElement("a");
downloadLink.download = "richard";
downloadLink.innerHTML = "Download File";
downloadLink.href = textToSaveAsURL;
downloadLink.onclick = this.destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink); 
downloadLink.click();

}

I hope you understand that your code has nothing to do with PDF.

Why is your code calling saveAsFile on only the last IMG element of each row?

Do you know what arguments can be passed to the Blob constructor? https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob

You are going to have to spend a lot of time figuring out what you really want to do and then debugging your code.

Ok thank you, as per given intro in printing http://gojs.net/latest/intro/printing.html i can see my diagram image in browser itself, how can i download that image ,can you give any notes or sample on that ,thanks in advance.

finally i got solution diagram to pdf export using jsPDF:

generateImages (width:any, height:any) {
console.log(width);
console.log(height);
// sanitize input
width = parseInt(width);
height = parseInt(height);
if (isNaN(width)) width = 100;
if (isNaN(height)) height = 100;
// Give a minimum size of 50x50
width = Math.max(width, 50);
height = Math.max(height, 50);
var imgDiv = document.getElementById(‘myImages’);
console.log(imgDiv)
imgDiv.innerHTML = ‘’; // clear out the old images, if any
var db = this.myDiagram.documentBounds.copy();
var boundswidth = db.width;
var boundsheight = db.height;
var imgWidth = width;
var imgHeight = height;
var p = db.position.copy();
//making images
for (var i = 0; i< boundsheight; i += imgHeight) {
var img:any
for (var j = 0; j < boundswidth; j += imgWidth) {
img= this.myDiagram.makeImage({
scale: 1,
type: “image/jpeg”,
background: “white”,
position: new go.Point(p.x + j, p.y + i),
size: new go.Size(imgWidth, imgHeight)
});
}
}
var doc = new jsPDF();
doc.addImage(img.src, ‘JPEG’, 15, 40, 180, 160);
//if you need more page use addPage();
// doc.addPage();
doc.save(‘diagram.pdf’);
}