Skip to main content

Making Documents with Curl

Written by Michelle Mitchell

Not using any of our example languages? Here are the basics, but let us know what you're using! That'll help us get the best examples.

Make a POST...

To make docs, send a POST request to this URL:

https://YOUR_API_KEY_HERE@docraptor.com/docs

...with this payload

Here's an example POST body payload in JSON. Note that when sending JSON, you'll need to set an HTTP header for Content-Type as application/json.

{
  "test": true,                                                    // test documents are free but watermarked
  "document_content": "<html><body>Hello</body></html>",           // supply content directly
  // "document_url": "http://docraptor.com/examples/invoice.html", // or use a url
  "type": "pdf",                                                   // pdf or xls or xlsx
  // "javascript": true,                                           // enable JavaScript processing
  // "prince_options": {
  //   "media": "screen"                                           // use screen styles instead of print styles
  //   "baseurl": "http://hello.com"                               // pretend URL when using document_content
  // }
}

curl

Here's how to do it with curl:

curl http://YOUR_API_KEY_HERE@docraptor.com/docs \
  --fail --silent --show-error \
  --header "Content-Type:application/json" \
  --data '{"test": true,
           "document_url": "http://docraptor.com/examples/invoice.html",
           "type": "pdf" }' > docraptor.pdf

The DocRaptor API returns the binary PDF contents, so this example redirects the output to a file called docraptor.pdf .

Did this answer your question?