Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda