Skip to content

Instantly share code, notes, and snippets.

@mfyz
Last active December 15, 2015 00:49
Show Gist options
  • Save mfyz/5175230 to your computer and use it in GitHub Desktop.
Save mfyz/5175230 to your computer and use it in GitHub Desktop.
html to pdf conversion using doc converter api
<?php
//set POST variables
$url = 'http://c.docverter.com/convert';
$fields = array('from' => 'html',
'to' => 'pdf',
'input_files[]' => "@/".realpath('input.html').";type=text/html; charset=UTF-8",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$fp = fopen('result.pdf', 'w');
fwrite($fp, $result);
fclose($fp);
die('Done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment