0

A Node JS application component makes the following call to the server where the response (res) contains a PDF file in the response body.

this.$http.get('/resource/download/' + file.id)
  .then((res) => {
    console.log('back w/ PDF');
  }
);

I can view the PDF data in the response body and have compared it to downloading the same PDF and it looks correct.

How can I display the response in a new tab in the browser so the user can view the PDF?

EDIT:

The "res" parameter return parameter from the $http.get() call is not a URL but the response object from the Node JS app on the server. In the response object the .data property contains the PDF. If this were written to a file it would be a PDF file.

The app interfaces w/ the Google Drive API and we are getting the PDF contents when the user clicks on a file name in our website. We can't provide a link to the PDF on the Google Drive directly because that would require the user to have shared access to Google Drive to view the PDF file.

Is there a way to put the PDF data in a separate browser tab or even embed it in an iFrame?

ChrisP
  • 9,796
  • 21
  • 77
  • 121

1 Answers1

0

You can try something like this

$http
  .get(serverUrl)
  .then(function(data){
   //data is link to pdf
   $window.open(data);
});     

Hope it helps

yue you
  • 2,206
  • 1
  • 12
  • 29
  • See my Edit to the question which elaborates on the problem. The return parameter from the get() call is not a URL but the response object from Node JS. – ChrisP Feb 07 '18 at 00:25