GoJS完整图片下载,而不仅仅是视口中的部分

时间:2018-09-05 08:48:52

标签: javascript angular image gojs

我正在尝试将图像下载为Blob。但是问题在于只有下载的图像部分位于视口中。我希望下载整个图像。

这是我正在使用的功能:

downloadER() {
    this.diagram.rebuildParts();
    const downloadCallback = (blob: any): void => {
      var url = window.URL.createObjectURL(blob);
      var reader = new FileReader();
      reader.onloadend = () => {
        var imageDataUrl = reader.result;
        var img = document.createElement("img");
        img.src = imageDataUrl; // For getting the height and width
        let pdf = new jspdf('p', 'mm', 'b2');
        var position = 0;
        pdf.setFontSize(20);
        pdf.text(breadcrumb, 250, 20, 'center');
        pdf.addImage(imageDataUrl, 'PNG', 0, 25, position, img.naturalWidth, img.naturalHeight);
        pdf.save(pdfTitle + ".pdf");
      };
      reader.readAsDataURL(blob);
    }
    let blob = this.diagram.makeImageData({ background: "white", returnType: "blob", callback: <any>downloadCallback});
  }

如何下​​载完整图像。

1 个答案:

答案 0 :(得分:0)

{ scale: 1 }添加到您的选项中,它将使用整个文档范围,而不仅仅是视口中的内容。