Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
how to get file content through c# in node js

I am getting blob of pdf file from other server which is on C# in node server when I am converting it to array buffer it's size is different from C# array buffer size and when I am opening it to browser it gives error "Failed to load PDF document."

This is my server side code

async post(param: any, body: any, endPoint: string, queryParams: string = '') 
  {    
    try 
    {
      if(queryParams == '') queryParams = param.destinationSlug + '/' + param.mainBranchId;
      const url = splendidAccountsEndPointsEnum.baseUrl + queryParams + endPoint;
      const offset = new Date().getTimezoneOffset().toString();
      const headerConfig = { headers: { 'X-Api-Key': param.apiKey, 'X-Api-Secret': param.apiSecret, 'X-App-Id': config.get<string>("splendidXAppId"), LocalDateTimeOffset: offset }}
      const response = await axios.post(url, body, headerConfig)      
        .then(function (response: any) 
        {
          return response?.data;
        })
        .catch(function (error: any) 
        {
          console.log(error);
          return error;
        });
      if (response?.status === 200) 
      { 
        console.log('success');
        return response?.data;
      }

      return response;
    }
    catch (err) 
    {
      console.error(err);
      console.log(err);
      return err;
    }    
  }

And this is my client side


let response = this.orderService.generateInvoicePrinting(this.selectedRows)
          .subscribe((res) => {
            var file = new Blob([res], {type: 'application/pdf'});
            var fileURL = URL.createObjectURL(file);
            saveAs(file, "invoices.pdf");
            window.open(fileURL);
            this.pdfSrc = fileURL;
            this.showPdf = true;
            this.showSuccess('Invoices have been generated successfully.');
            this.selectedRows = [];
          },
          error => {
            this.showError('Invoices have not been generated successfully.');
          }); 

generateInvoicePrinting(orders: any): Observable<any>
  {
    const url = `${environment.apiUrl}api/Order/printInvoices/pdf`;
    return this.http.post(url, orders, { headers: new HttpHeaders({ 'Content-Type': 'application/json' }), observe: 'response', responseType: 'blob' }).pipe(
      map(res => res.body),
    );
  }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!