PDF Header by JavaScript / jQuery

-1

How to pass the PDF header via JavaScript / jQuery?

I need to print a page, that is, when the user accesses it, it already sends the PDF header and sends it to download. How to do this by JS?

    
asked by anonymous 09.06.2014 / 18:42

1 answer

1
The syntax for sending a request header with jQuery would be:

$.ajax({

    url: "/path/to/file.ext",
    beforeSend: function( xhr ) {

        xhr.setRequestHeader( 'Content-type', 'application/pdf' );
    }

}).done( function( response ) {

    // Dom something
})

However, unless this is a mistake, this will not have the desired result because it is a Request Header , that is, it indicates to the receiving program, defined in the AJAX URL that a PDF request would be made , rather than a Response Header that tells the browser to treat that output as a PDF.

I have never seen any practical applications, but I imagine that sending this Request Header would allow the receiving application to work with the raw data / p>     

09.06.2014 / 19:26