This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Odd pdf response

ad633 wrote on 2012-03-22:
I'm sending raw HTML to the API with an ajax call in JS and I'm getting an odd response.
Not quite sure if I'm doing anything wrong.


My code:
var printPage = function(){
                url: 'http://localhost:8080/var/proxy/pdfcrowd/rawhtml.json',
                data: {
                    "src": data,
                    "username": username,
                    "key": apiToken
                type: 'POST',
                success: function(dataResponse){
                }, error: function(a,b,c) {

I'm getting a lot of those unknown things/question marks in the response.
The dataResponse:

Thanks in advance!

Kind regards,
support wrote on 2012-03-22:

the response looks correctly, it is a PDF file. Since you are printing the response to a console you are seeing raw PDF data. Try to open any PDF file in a text editor and it will look similarly.
ad633 wrote on 2012-03-23:

Thank you for the quick reply.

How would I be able to let the user save this pdf when I receive it with the response?

Kind regards,
support wrote on 2012-03-23:
As far as I know, from security reasons you are not allowed to save data to a local file from Javascript.

One option would be

  1. Create a PDF and store it somewhere on your server
  2. Send the URL of the saved PDF in the ajax response instead of PDF raw data
  3. set document.location.href to the received URL

Another option would be to use a form to post to your server, an example is shown here:,542,545#msg-545