无法使用Angular 4捕获pdf响应表单服务器

时间:2017-11-05 09:35:39

标签: angular http pdf

我的组件中的代码如下

$string ='';
$length = 60;
$pattern = 'abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789';
$hashList = array('sha256','sha384','sha512','ripemd256','ripemd320','openssl_random_pseudo_bytes');
$randNumber = mt_rand(0, 6);

for($i=0; $i<$length; $i++)
{
    $string .= $pattern[rand()%strlen($pattern)];
}

switch ($randNumber) {

    case 0:
    return substr(hash($hashList[$randNumber],$string),0,$length);    
    break;

    case 1:
    return substr(hash($hashList[$randNumber],$string),0,$length);
    break;

    case 2:
    return substr(hash($hashList[$randNumber],$string),0,$length);
    break;

    case 3:
    return substr(hash($hashList[$randNumber],$string),0,$length);
    break;

    case 4:
    return substr(hash($hashList[$randNumber],$string),0,$length);
    break;

    case 5:
    return substr(bin2hex($hashList[$randNumber]($length)),0,$length);
    break;

    default:
    return $string;
    break;

}

我在电话会议后得到的回复错误

错误:

printPayOrders() {
    console.log(this.orders);
    const options = {
      headers: new HttpHeaders({
        "Content-Type": "text",
        Accept: "application/pdf"
      })
    };
    this.http
      .post("/payorder/printpayorder", { payorder: this.orders }, options)
      .subscribe(
        res => {
          console.log(res);
          const file = new Blob([res], { type: "application/pdf" });
          const fileURL = URL.createObjectURL(file);
          console.log(fileURL, "------------------fileurl------------");
          window.open(fileURL);
        },
        err => {
          console.log(err);
          console.log("Error occured");
        }
      );
  }

0 个答案:

没有答案