Although it's an old question, however just want to share another solution for future reference.
GroupDocs.Conversion Cloud REST API is another option to convert back and forth between over 65+ types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and much more.
cURL sample Code:
### Retrieve access token
### TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
curl --request POST https://api.groupdocs.cloud/connect/token
--header "Content-Type: application/x-www-form-urlencoded"
--data "grant_type=client_credentials&client_id=[APP_SID]&client_secret=[APP_KEY]"
### Convert and Add Watermark
curl --request POST "https://api.groupdocs.cloud/v2.0/conversion"
--header "authorization: Bearer [ACCESS_TOKEN]"
--header "accept: application/json"
--header "Content-Type: application/json" --data "{ "FilePath": "test_doc.docx", "Format": "pdf", "ConvertOptions": { "FromPage": 1, "PagesCount": 1, "WatermarkOptions": { "text": "Watermark" } }, "OutputPath": "Output"}"
I work with Aspose as developer evangelist.