REST API conversion PDF to HTML

Try PDFix REST API for PDF conversion

  • Display your PDF files as HTML
  • Fill in your PDF forms in HTML and submit form data

PDFix REST API Demo is a project powered by PDFix API that allows web developers and administrators to display their PDF documents in HTML which brings new possibilities to display additional rich content within the PDF, track user activity and much much more. All this is not available when reading PDF as PDF in the browser or in a PDF Viewer. With PDFix REST API you can have full control over your PDF files on your web server.

Ho to use the PDFix REST API

/convert

POST /1/convert HTTP/1.1
Host: api.pdfix.net:8080
Cache-Control: no-cache
Postman-Token: b91dd5e8-1cb5-9fdb-0b1d-3cc8afaf97a6

{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}
/** LibCurl **/
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "http://api.pdfix.net:8080/1/convert");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "postman-token: 76b92237-6ca2-d2b9-ac77-86263119d1ed");
headers = curl_slist_append(headers, "cache-control: no-cache");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}");

CURLcode ret = curl_easy_perform(hnd);
curl -X POST -H "Cache-Control: no-cache" -H "Postman-Token: 83d52bc8-4220-39fd-1276-f01d10b00209" -d '{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}' "http://api.pdfix.net:8080/1/convert"
/** RestSharp **/
var client = new RestClient("http://api.pdfix.net:8080/1/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "f3ea91a5-911f-495d-3cc1-302803f30613");
request.AddHeader("cache-control", "no-cache");
request.AddParameter("undefined", "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "http://api.pdfix.net:8080/1/convert"

	payload := strings.NewReader("{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("cache-control", "no-cache")
	req.Header.Add("postman-token", "3490db21-50a4-2e96-1348-88a34bd29c0b")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
/** OKHTTP **/
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}");
Request request = new Request.Builder()
  .url("http://api.pdfix.net:8080/1/convert")
  .post(body)
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "f8dffe39-00bd-d04c-9ab4-1fae8f10510e")
  .build();

Response response = client.newCall(request).execute();
/** Unirest **/
HttpResponse response = Unirest.post("http://api.pdfix.net:8080/1/convert")
  .header("cache-control", "no-cache")
  .header("postman-token", "aa12511a-7f20-f471-e460-243a98ac6b7f")
  .body("{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}")
  .asString();
/** Jquery AJAX **/
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://api.pdfix.net:8080/1/convert",
  "method": "POST",
  "headers": {
    "cache-control": "no-cache",
    "postman-token": "ef4fcf06-c893-9476-77e6-1c3932b85817"
  },
  "data": "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
/** XHR **/
var data = "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "http://api.pdfix.net:8080/1/convert");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "4ed81fa2-486c-a74e-b29a-628a81a38f0f");

xhr.send(data);
/** Native **/
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "api.pdfix.net",
  "port": "8080",
  "path": "/1/convert",
  "headers": {
    "cache-control": "no-cache",
    "postman-token": "06c32d74-52c1-8777-1c7b-c65e7d3f8a72"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write("{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}");
req.end();
/** Request **/
var request = require("request");

var options = { method: 'POST',
  url: 'http://api.pdfix.net:8080/1/convert',
  headers: 
   { 'postman-token': '62e5d3d3-28c2-cbe0-056a-a59f07d322d5',
     'cache-control': 'no-cache' },
  body: '{\n\t"authorize" : {\n\t\t"email" : "your@email.com",\n\t\t"key" : "license_key"\n\t},\n\t"convert" : {\n\t\t"url" : "http://pdfix.net/pdf/Climate_Change.pdf",\n\t\t"id" : "",\n\t\t"page" : 1\n\t}\n}' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
/** Unirest **/
var unirest = require("unirest");

var req = unirest("POST", "http://api.pdfix.net:8080/1/convert");

req.headers({
  "postman-token": "f7b5aa43-cd87-0177-f6e9-24d86f8afb55",
  "cache-control": "no-cache"
});

  req.send("{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}");

req.end(function (res) {
  if (res.error) throw new Error(res.error);

  console.log(res.body);
});
/** NSURL **/
#import 

NSDictionary *headers = @{ @"cache-control": @"no-cache",
                           @"postman-token": @"e7afbfc0-e128-6d38-be13-a1429739d353" };

NSData *postData = [[NSData alloc] initWithData:[@"{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}" dataUsingEncoding:NSUTF8StringEncoding]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.pdfix.net:8080/1/convert"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                if (error) {
                                                    NSLog(@"%@", error);
                                                } else {
                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                    NSLog(@"%@", httpResponse);
                                                }
                                            }];
[dataTask resume];
/** Cohttp **/
open Cohttp_lwt_unix
open Cohttp
open Lwt

let uri = Uri.of_string "http://api.pdfix.net:8080/1/convert" in
let headers = Header.init ()
  |> fun h -> Header.add h "cache-control" "no-cache"
  |> fun h -> Header.add h "postman-token" "edd24f62-947a-81c8-6bd4-6908b7248d5a"
in
let body = Cohttp_lwt_body.of_string "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}" in

Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
  (* Do stuff with the result *)
/** HttpRequest **/

$request = new HttpRequest();
$request->setUrl('http://api.pdfix.net:8080/1/convert');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => '8a822536-58f5-79a4-9dc7-33a41aca4f0f',
  'cache-control' => 'no-cache'
));

$request->setBody('{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
/** pecl_http **/

$request = new HttpRequest();
$request->setUrl('http://api.pdfix.net:8080/1/convert');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => '8a822536-58f5-79a4-9dc7-33a41aca4f0f',
  'cache-control' => 'no-cache'
));

$request->setBody('{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
/** cURL **/

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://api.pdfix.net:8080/1/convert",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "postman-token: 40b89ffb-e4e9-15c0-a033-ff23a17dacff"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
/** http.client (Python 3) **/
import http.client

conn = http.client.HTTPConnection("api.pdfix.net:8080")

payload = "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}"

headers = {
    'cache-control': "no-cache",
    'postman-token': "8fe70a18-c92e-d6c2-cdad-0af415609ad9"
    }

conn.request("POST", "/1/convert", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
/** Requests **/
import requests

url = "http://api.pdfix.net:8080/1/convert"

payload = "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}"
headers = {
    'cache-control': "no-cache",
    'postman-token': "b587e4a0-1445-e60a-90f2-efba1161ba7b"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
/** NET::Http **/
require 'uri'
require 'net/http'

url = URI("http://api.pdfix.net:8080/1/convert")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["cache-control"] = 'no-cache'
request["postman-token"] = '5f1e1bac-b828-28b3-def8-48f0c2659da2'
request.body = "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}"

response = http.request(request)
puts response.read_body
/** wget **/
wget --quiet \
  --method POST \
  --header 'cache-control: no-cache' \
  --header 'postman-token: e12c0d26-dc2d-1b40-07be-afc3b664d76c' \
  --body-data '{\n	"authorize" : {\n		"email" : "your@email.com",\n		"key" : "license_key"\n	},\n	"convert" : {\n		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",\n		"id" : "",\n		"page" : 1\n	}\n}' \
  --output-document \
  - http://api.pdfix.net:8080/1/convert
/** Httpie **/
echo '{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}' |  \
  http POST http://api.pdfix.net:8080/1/convert \
  cache-control:no-cache \
  postman-token:027cd547-8094-9560-7fce-17ad19a38338
/** cURL **/
curl --request POST \
  --url http://api.pdfix.net:8080/1/convert \
  --header 'cache-control: no-cache' \
  --header 'postman-token: bf709def-a1fc-7a22-ceb7-e62b5dd847c8' \
  --data '{\n	"authorize" : {\n		"email" : "your@email.com",\n		"key" : "license_key"\n	},\n	"convert" : {\n		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",\n		"id" : "",\n		"page" : 1\n	}\n}'
/** NSURL **/
import Foundation

let headers = [
  "cache-control": "no-cache",
  "postman-token": "1f24f348-7dcd-c508-68a6-949394c58369"
]

let postData = NSData(data: "{
	"authorize" : {
		"email" : "your@email.com",
		"key" : "license_key"
	},
	"convert" : {
		"url" : "http://pdfix.net/pdf/Climate_Change.pdf",
		"id" : "",
		"page" : 1
	}
}".dataUsingEncoding(NSUTF8StringEncoding)!)

var request = NSMutableURLRequest(URL: NSURL(string: "http://api.pdfix.net:8080/1/convert")!,
                                        cachePolicy: .UseProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.allHTTPHeaderFields = headers
request.HTTPBody = postData

let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    println(error)
  } else {
    let httpResponse = response as? NSHTTPURLResponse
    println(httpResponse)
  }
})

dataTask.resume()
/** RestSharp **/
var client = new RestClient("http://api.pdfix.net:8080/1/convert");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "f3ea91a5-911f-495d-3cc1-302803f30613");
request.AddHeader("cache-control", "no-cache");
request.AddParameter("undefined", "{\n\t\"authorize\" : {\n\t\t\"email\" : \"your@email.com\",\n\t\t\"key\" : \"license_key\"\n\t},\n\t\"convert\" : {\n\t\t\"url\" : \"http://pdfix.net/pdf/Climate_Change.pdf\",\n\t\t\"id\" : \"\",\n\t\t\"page\" : 1\n\t}\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Legend:
email - registered email address
key - license key (go to http://pdfix.net/#download to get trial key for Windows platform)
url - url of the pdf file to convert
id - file identifier (used when processing pdf multiple times)
page - the page number to convert (currently unused)
{
  "id": "b5e710c48017d14cd58ae98316518803",
  "error": "Authorization fail\r\n",  
  "errorcode": 0,
  "url": "http://app.pdfix.net:8080/api/html/b5e710c48017d14cd58ae98316518803/index.html"
 }
Legend:
id - unique file identifier can be used as id in request
error - erorr string
errorcode - error code (0 - no error)
url - the url of converted file

Powered by http://pdfix.net