Home > Blockchain >  Angular - Failing to open Post response which a PDF file
Angular - Failing to open Post response which a PDF file

Time:04-05

I want to view the PDF file which is my post response, below is my post code, Any help

printQuotation(quote: Quotes) {
    const requestBody = {
      quotationId: quote.quotationId,
      vehicleRegistration: quote.vehicleRegistration,
      insurerId: quote.insurerId,
      insurer: quote.insurer,
      calculationResponse:quote.calculationResponse,
      addOns: quote.addOns,
    };
    this.printService.postToUrl('/quotations-print', requestBody,).subscribe(

      {
      next: (res) => {
        this.printOption=true;
        
      },
    }
    )

  }

CodePudding user response:

I think you want add 'blob' to request header :

 postToUrl(url,data = null,params = null,responseType = null,){

      return this.http.post(url, data, {
      params,
      responseType,
    });}

and on the function calling part also pass the 'blob' as reponseType

printQuotation(quote: Quotes) {
const requestBody = {
  quotationId: quote.quotationId,
  vehicleRegistration: quote.vehicleRegistration,
  insurerId: quote.insurerId,
  insurer: quote.insurer,
  calculationResponse:quote.calculationResponse,
  addOns: quote.addOns,
};
this.printService.postToUrl('/quotations-print', requestBody,null,'blob').subscribe(

  {
  next: (res) => {
    this.printOption=true;
    
  },
}
)}

if not work please let me know...

NB: you want to send the pdf as blob data

  • Related