DocRaptor HTML TO PDF API

How to create a PDF with Rotated Text & Images

Dynamically creating PDFs with rotated text and images is simple with DocRaptor's HTML to PDF API. You can use the same CSS transform properties typically used in web development, like this:

#text {
  transform: rotate(-30deg);
}

#image {
  transform: rotate(30deg);
}

This transforms the following HTML:

<div id="text">Rotate me!</div>
<div id="image"><img src="https://docraptor-production-cdn.s3.amazonaws.com/tutorials/raptor.png" /></div>

To see how it works with the DocRaptor HTML to PDF API in your programming language, check out the below rotated-content samples:

Select Your Language

Using DocRaptor's API

Below are the basics of using DocRaptor's HTTP API. It can easily be used in any programming language, but if we don't have a native agent for your language, please let us know! That'll help us write the best examples and agents.

The API key shown here, YOUR_API_KEY_HERE, actually works! Use it for testing without creating an account. The only requirement is test mode must be used (test parameter set to true).

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

https://YOUR_API_KEY_HERE@api.docraptor.com/docs

Send JSON-encoded API parameters (you'll need to set an HTTP header for Content-Type as application/json). These are the only required parameters:

{
  "type": "pdf",
  "document_content": "Hello World!"
}

Generating the Document with cURL

Here's a completely functional code sample for this tutorial:

cat <<-'DOCUMENT_OPTIONS' > docraptor_parameters.json
  {
    "test": true,
    "document_type": "pdf",
    "document_content": "<div id=\"text\">Rotate me!</div><div id=\"image\"><img src=\"https://docraptor-production-cdn.s3.amazonaws.com/tutorials/raptor.png\" /></div><style>#text {transform: rotate(-30deg);}#image {transform: rotate(30deg);}</style>"
  }
DOCUMENT_OPTIONS

curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \
  --fail --silent --show-error \
  --header "Content-Type:application/json" \
  --data @docraptor_parameters.json \
  > rotated-text-images.pdf

Downloads

Here are all the files you need to follow this tutorial:

Related Tutorials & Documentation

See the complete PDF tutorial list or review the documentation for additional info, such as generating asynchronous documents.

Ready to get started? Try DocRaptor for free with unlimited test documents.