GemDocs is a service that converts HTML to PDF. To create a PDF file is required: html code, which you want to convert your image token the authentication request to the server.

1. How to get a token?

Login to customer zone and select a service GemDocs. From the left menu, select "Generate a new token." Your token pojewi in the box below.

Once generated token is valid for one year.

2. How to convert a file?

The following code examples present functions of transmitting the html code to the server GemDocs and drawing the resulting PDF file in a variable.
function get_pdf($gemdocs) { $token = '[token_gemdocs]'; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_POST => 1, CURLOPT_URL => '', CURLOPT_POSTFIELDS => array('html'=>$gemdocs), CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$token), CURLOPT_RETURNTRANSFER => true )); $result = curl_exec($ch); curl_close($ch); return $result; }
class Gemdocs require 'uri' require 'net/http' require 'net/https' uri = URI.parse("") headers = {'Authorization' =>'Bearer [token_gemdocs]'} html = "html=..." http =, uri.port) resp =, html, headers) puts resp.body end
import urllib import urllib2 code = '...' url = '' values = {'html': code} headers = { 'Authorization' : 'Bearer [token_gemdocs]' } data = urllib.urlencode(values) req = urllib2.Request(url, data, headers) response = urllib2.urlopen(req) the_page = print(the_page)
import urllib.parse import urllib.request document = '..' url = '' values = {'html' : document} headers = { 'Authorization' : 'Bearer [token_gembit]' } data = urllib.parse.urlencode(values) data = data.encode('utf-8') req = urllib.request.Request(url, data, headers) with urllib.request.urlopen(req) as response: the_page = print(the_page)
package gemdocs; import; import; import; import; import; import; public class GemDocs { public static void main(String[] args) throws Exception { String data = URLEncoder.encode("html", "UTF-8") + "=" + URLEncoder.encode("...", "UTF-8"); URL url = new URL(""); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setRequestProperty( "Authorization", "Bearer [token_gembit]"); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); } }

The HTML code for the server pass the POST method, by setting "html".

Then I send in the header token. The header should be titled Authorization. Token should be preceded by a string: Bearer

Authorization: Bearer [token]

Remember to include a space before token.

The result of this query will be a PDF file ready for download or display.

Copyright © 2015 Gembit