Get started
API Endpoint
http://gadre.co.in/pdfUtility/createPdf
This API provides programmatic generate PDF by given HTML data and settings options.
To use this API, you need an API key. Please contact us at mandar.paranjape@gadreinfotech.com to get your own API key.
get characters
# Here is a curl example
$data = array(
"Template"=>"<p>Hello World</p>",
"FileName"=>"first_demo",
"PaperSize"=>"Legal",
"Orientation"=>"P",
"margin_left" => 15,
"margin_right" => 15,
"margin_top" => 15,
"margin_bottom"=>15,
"margin_header" =>15,
"margin_footer"=>15,
"font_size" => 10,
"ShowHeater" =>false,
"HeaderContent"=>"Left|center|right",
"ShowFooter" =>false,
"FooterContent"=>"Left|center|right"
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://gadre.co.in/pdfUtility/createPdf.php",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"authkey: ca24b83b-d49c-4ef0-8259-6cc52af9f89c",
"cache-control: no-cache",
"content-type: application/json",
"postman-token: cb463e8d-ee3c-a03e-4457-5d18bb578b06"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
To generate PDF file from HTML you need to make a POST call to the following url :
http://gadre.co.in/pdfUtility/createPdf.php
Result example :
On Success
{
"code":200,
"url":"gadre.co.in\/pdfUtility\/uploads\/first_demo.pdf",
"fileName":"first_demo.pdf"
}
On Error
{
"code":401,
"error":"Invalid auth key."
}
HEADER PARAMETERS
| Field | Description |
|---|---|
| authkey | Your API key. |
| content-type | should be 'application/json' |
QUERY PARAMETERS
| Field | Description & default Values |
|---|---|
| Template | Pass your HTML template. if there is different language then add language in html tag like <html lang="mr"> and add meta tag >meta charset="utf-8"> in header |
| FileName | Pass name want to save file with name |
| PaperSize | Default paper size is A4 you can pass paper size per your requirement
|
| Orientation | BLANK or omitted leaves the current orientation unchanged. 'L' or 'landscape' for Landscape 'P' or 'portrait' for Portrait |
| margin_left | Pass value in mm. Default value is 5 |
| margin_right | Pass value in mm. Default value is 5 |
| margin_top | Pass value in mm. Default value is 5 |
| margin_bottom | Pass value in mm. Default value is 5 |
| margin_header | Pass value in mm. Default value is 5 |
| margin_footer | Pass value in mm. Default value is 5 |
| font_size | Default font size is 12 |
| ShowHeater | In want to show header value is true else false. default value true. current date wll get show in page header |
| HeaderContent | Format to show header si Left content |center content|right content. Keep blank if don't want show any position text |
| ShowFooter | In want to show header value is true else false. default value true. show domain url and page no. in footer |
| FooterContent | Format to show header si Left content |center content|right content. Keep blank if don't want show any position text |
Errors
The API uses the following error codes:
| Error Code | Meaning |
|---|---|
| 200 | PDF generated successfully |
| 401 |
Unknown or unvalid secret_key. This error appears if you use an unknow API key or if your API key expired.
|
| 210 | Some header parameters missing. |
| 211 | Some API parameters missing. |