You would need to pass the responseType in your service call

$http.post('/Service-URL', dataTO, {responseType: 'arraybuffer'});

then in the success of your data call this should open up pdf in a new window:-

    getDocument()
        .success(function(data) {
            var file = new Blob([data], { type: 'application/pdf' });
            var fileURL = URL.createObjectURL(file);
            window.open(fileURL);
    })

From this answer :- https://stackoverflow.com/a/21730535/3645957 by https://stackoverflow.com/users/2688545/michael

Answer from aniltilanthe on Stack Overflow
🌐
GitHub
github.com › mozilla › pdf.js › issues › 6047
Convert Byte array to pdf · Issue #6047 · mozilla/pdf.js
May 25, 2015 - Decoded msg on client = %PDF-1.4 %ÓôÌá 1 0 obj << /CreationDate(D:20150401230804-04'00') /Creator(PDFsharp 1.32.2608-g (www.pdfsharp.net\)) /Producer(PDFsharp 1.32.2608-g (www.pdfsharp.net\))
Published   May 25, 2015
Author   jagrutidave
🌐
Experts Exchange
experts-exchange.com › questions › 25629636 › Pass-byte-array-to-javascript-and-convert-the-byte-array-to-PDF-in-javascript.html
Solved: Pass byte[] array to javascript and convert the byte array to PDF in javascript. | Experts Exchange
March 31, 2010 - Sounds like you have the pdf already on the server or on someone else's server If you have it on your own server, ajax a LINK to the pdf and open the pdf in an iframe or a new window If it is on someone else's server or web service, get the pdf on your server and send it as application/pdf to the browser in an iframe or new window You cannot ajax a pdf file to the browser - even if you had converted it to b64 or some other textual thing, because JS cannot show it this COULD have worked, but I am sure it does not w=window.open('application
🌐
Forumotion
kapow.forumotion.net › kapow data extraction › pdf saved as byte array - converting back to pdf
PDF saved as byte array - converting back to PDF
May 18, 2022 - Use Execute Javascript step and custom javascript with expression. >> function byte2base64( buffer ) { var binary = ''; var bytes = new Uint8Array( buffer ); var len = bytes.byteLength; for (var i = 0; i < len; i++) { binary += String.fromCharCode( ...
🌐
Code Forum
codeforum.org › software & web development › front-end development › javascript
JavaScript - IS there a way to convert docx byte array to pdf ? | Code Forum - Where your coding journey begins
May 13, 2022 - It covers how to convert docx or word to pdf in nodejs and javascript application npm packages docx-to-pdf libreoffice-convert example
🌐
Stack Overflow
stackoverflow.com › questions › 44434775 › byte-array-to-pdf-through-javascript
java - Byte array to pdf through javascript - Stack Overflow
June 8, 2017 - String genericResponseS=""; OrderRequest orderRequest=null; String orderId=request.getParameter("orderId"); FileOutputStream fileOuputStream=null; try { //$('#productName').val() orderRequest=new OrderRequest(); orderRequest.setOrderId(Long.valueOf(orderId)); orderRequest.setUserId(userBean.getUserID()); //priceBookRequest.setCurrencyId(Long.parseLong(currencyId)); byte[] arrayB=MobileServiceOrder.generateOrderPDF(orderRequest, request) ; /*response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment;filename=" + "abc.pdf"); fileOuputStream = new FileOutput
Find elsewhere
🌐
C# Corner
c-sharpcorner.com › article › convert-byte-array-into-pdf-and-open-it-inside-custom-dialog-box-in-angular
Convert Byte Array Into PDF And Open It Inside Custom Dialog box In Angular
January 11, 2023 - We will get byte array as an response from API and same we need to encode and convert into PDF inside Custom Dialog box in Angular, where you can fire events on closing of dialog to fire another event.
🌐
DEV Community
dev.to › letsbelopez › how-to-load-a-pdf-in-a-browser-from-a-pdf-byte-array-56ic
How to Load a PDF in a Browser from a PDF Byte Array - DEV Community
March 23, 2020 - Here's my solution. I ended up using an embed tag and make the src attribute equal to the api endpoint that was returning the byte array. <div class="pdf"> <embed src="https://api_url/path/to/endpoint" type="application/pdf" /> </div>
🌐
CodeProject
codeproject.com › Questions › 100792 › How-to-convert-a-byte-array-to-a-pdf
How to convert a byte array to a pdf - CodeProject
May 3, 2016 - Artificial Intelligence · ASP.NET · JavaScript · Internet of Things · C / C++ / MFC> ATL / WTL / STL · Managed C++/CLI · C# Free Tools · Objective-C and Swift · Database · Hardware & Devices> System Admin · Hosting and Servers · Java · Linux Programming ·
🌐
Stack Overflow
stackoverflow.com › questions › 16397471 › javascript-converting-pdf-to-bytes-array-and-rendering-the-pdf-in-ui-using-html
JavaScript: converting pdf to bytes array and rendering the pdf in UI using HTML5 - Stack Overflow
February 7, 2019 - PDFJS.workerSrc = "pdf.worker.js"; //File from the input element inputElement.onchange = function(event) { var file = event.target.files[0]; //Read the file locally using file reader var fileReader = new FileReader(); fileReader.onload = function() { var typedarray = new Uint8Array(this.result); // Render PDF PDFJS.getDocument(typedarray).then(function(pdf) { pdf.getPage(1).then(function getPageHelloWorld(page) { var scale = 1.5; var viewport = page.getViewport(scale); var canvas = document.getElementById('the-canvas'); var context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width; page.render({canvasContext: context, viewport: viewport}); }); }); }; // Read the file into array buffer.
🌐
CodeSandbox
codesandbox.io › s › n9ojpm9opp
Save response as PDF - CodeSandbox
December 6, 2017 - fetch data\nconvert to byte array\nsave as PDF
Published   Dec 06, 2017
Author   savtwo
🌐
Stack Overflow
stackoverflow.com › questions › 53912526 › convert-bytearray-into-pdf-javascript
java - convert bytearray into pdf javascript - Stack Overflow
i'm trying to download a pdf report (using jasperReports) directly from browser... my JS code is above: if (generateReport) { Loader.get(`${window.location.origin}/api/${Version.TRIP}/expenses/
🌐
Medium
medium.com › @riccardopolacci › download-file-in-javascript-from-bytea-6a0c5bb3bbdb
Download file in JavaScript— From ByteA | by Riccardo Polacci | Medium
July 10, 2018 - downloadPdf(id: number) { this.http.post('/api/documents', { id }) .subscribe( (base64Pdf: string) => { const arrayBuffer = base64ToArrayBuffer(base64Pdf); createAndDownloadBlobFile(arrayBuffer, 'testName'); }, error => console.error(error) ) } id: The id of the document we want to download (optional) base64Pdf: The result from the call. This is what the server returns, in my case is a bytea PDF file base64 encoded.
🌐
GitHub
github.com › mozilla › pdf.js › issues › 9142
Display pdf as byte-array · Issue #9142 · mozilla/pdf.js
November 16, 2017 - You must be signed in to change notification settings · Fork 10.5k · Star 52.3k · New issueCopy link · New issueCopy link · Closed · Closed · Display pdf as byte-array#9142 · Copy link · abrasat · opened · on Nov 16, 2017 · Issue body actions · Is it possible to display a pdf from a byte-array in memory, instead from a Uri ?
Author   abrasat
🌐
ASPSnippets
aspsnippets.com › questions › 210417 › Preview-and-download-PDF-from-byte-array-using-jQuery-Ajax-in-ASPNet-Core-MVC
Preview and download PDF from byte array using jQuery Ajax in ASPNet Core MVC
October 14, 2021 - // For preview JS function GetDocPreview(fileLeafRef, ID, SitePath, FileUrl) { var urlPrv = $('#urlPrv').data('request-url'); $.ajax({ type: "POST", url: urlPrv, // do not hard code your url's data: { 'fileLeafRef': fileLeafRef, 'ID': ID, 'SitePath': SitePath, 'FileUrl': FileUrl, 'DeptSiteColID': $("#DeptSiteColID").val(), 'staffID': $("#hdnStaffID").val() }, success: function (data, jqXHR, response) { if (data.success) { var bytes = _base64ToArrayBuffer(data.message); // saveByteArray("Sample Report", bytes); var getFile = new Blob([bytes], { type: data.type }); var fileURL = URL.createObjectURL(getFile); $("#embedPreview").attr('src', fileURL); } } }); }