Text doesn't show on PDF acquired from express API (Angular 8)

Viewed 49

Specifically, when I try to display it with a pdf viewer, I get the error "unknown block type in flate stream". Everything else on the pdf works (pages, table of contents jumping to the correct page, title, etc). I have confirmed that the API works with a postman get request, which correctly displays the full pdf.

Here is the get request:

    public makeHttpOrchestrationPdfPost(url, data): Observable<any> {
    let headers = new HttpHeaders();
    headers = headers.set('Accept', 'application/pdf');
    return this.http.post(url, data, { headers: headers, responseType: 'blob'})
  }

Here is what calls the get request:

public getFile(filename:string) {

var postData = {};
postData['function'] = '/objectstorage/' + filename
postData['requestType'] = 'GET'
return this.makeHttpOrchestrationPdfPost('/get_orchestration_response', postData);
}

And here is the code to display the PDF (I also use ngx-extended-pdf-viewer, but the results are the same as window.open):

this.getFile(this.data.filename).subscribe((success) => {
      var blob = new Blob([success], { type: 'application/pdf' });
      var url = URL.createObjectURL(blob);
      window.open(url);

I have tried arraybuffer request type, displaying the blob without using the blob constructor, displaying the arraybuffer, converting the arraybuffer to blob, and any other combination I could think of, but it all results in the same issue of a working pdf, just with no text. Thanks in advance for any help!

0 Answers
Related