从新标签页打印图像

时间:2019-07-08 17:12:05

标签: javascript reactjs twitter-bootstrap

我有一个功能Toggle2,需要使用它在新选项卡中打开数据。我可以动态打印数据,但是图像没有显示出来。它正在像[对象对象]一样打印图像。

toggle2 = event => {
    let test = {};
    test = this.state.tabledata;
    const entries = Object.values(test);
    console.log(entries);

    const entries1 = Object.entries(entries[1]);

    let x = window.open();
    x.document.open();
    x.document.write("<html><head><title>Certificates</title>");
    x.document.write("</head><body>");

    for (const [key, property] of entries1) {
      const entries2 = Object.entries(property);

      for (const [key1, property1] of entries2) {
        if (key1 === "Location") {
          var pdfLocation = property1;
        } else if (key1 === "RecptEmail") {
          var pdfEmail = property1;
        } else if (key1 === "ProjectName") {
          var pdfProjectName = property1;
        } else if (key1 === "AwardReasonDesp") {
          var pdfAwardReason = property1;
        } else if (key1 === "Comments") {
          var pdfComments = property1;
        }
      }

      let string =
        pdfLocation +
        " " +
        pdfEmail +
        " " +
        pdfProjectName +
        " " +
        pdfAwardReason +
        " " +
        pdfComments +
        " ";

      x.document.write()
      x.document.write(string);
    }
    x.document.write("</body></html>");
    x.document.close();
  };

0 个答案:

没有答案