Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
PDF Typescript createObjectURL not opening

I am getting this error from Chrome failed to load PDF document. I am returning a byte[] as the Content and ContentType is set to application/pdf. Is this the correct way to display a PDF file in Typescript using a ajax Post?

Ts

printItems(versionKeys: string[]): JQueryPromise<any> {
        console.log('printItems');
        $.ajax({
            type: "post",
            contentType: "application/json",
            data: JSON.stringify(versionKeys),
            url: this.apiUrls.PrintTemplates,
            success: function (data, status, xhr) {
                console.log(data);
                var file = new Blob([data.Content], { type: data.ContentType });
                var fileURL = URL.createObjectURL(file);
                window.open(fileURL);
                console.log('success');
            }
        });

        return;
    }

Controller

   [HttpGet, HttpPost]
        [ApplicationApiAuthorize("Administrator, ContentManager")]
        public IHttpActionResult PrintTemplates([FromBody] List<string> versionKeys)
        {

            var templates = versionKeys
                    .Select(v => TemplatesDataService.GetTemplate(v))
                    .ToList();

            var templateIds = templates.Select(b => b.Id).ToList();

            var templateFile = TemplatesDataService.PrintTemplate(templateIds);

          
            return Ok(templateFile);
        }

Chrome Error

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda