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
🌐
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>
🌐
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 - >> function byte2base64( buffer ... i ] ); } return window.btoa( binary ); } var bytes = byte2base64(<<+longText+>>); var pdfUrl = "data:application/pdf;base64,"+bytes; window.open(pdfUrl);<< ... » Converting Excel to PDF ...
🌐
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
Find elsewhere
🌐
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
🌐
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.
🌐
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); } } }); }
🌐
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.
🌐
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 - Free source code and tutorials for Software developers and Architects.; Updated: 11 Aug 2010
🌐
Apryse Community
community.apryse.com › technical support › webviewer
Loading PDF file using blob of byte array or local file using open file feature of webviewer is giving error - WebViewer - Apryse Community
March 11, 2024 - Getting console erros on loading pdf file in webviewer using blob of byte array getting from Asp.net core web Api. I want to load pdf file into Webviewer control using javascript, I tried so many ways to load document but getting console error listed below: it is some information printed on console 1. Build: “OS85LzIwMjF8NTU4Zjg4N2Fk” 2. Core version: “8.1.0” 3. Full API: false 4. UI version: “8.1.0” 5. WebViewer Server: false Error Download Failed lean/PDFNetCWasm.gz.wasm Uncaught (in...
🌐
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