Last active
December 15, 2015 00:49
-
-
Save mfyz/5175230 to your computer and use it in GitHub Desktop.
html to pdf conversion using doc converter api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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