Docverter / docverter

Docverter Server
Other
831 stars 100 forks source link

Is the API down? #53

Closed wisejoy7 closed 7 years ago

wisejoy7 commented 7 years ago

I have been trying to convert files using the same code that was working yesterday but the files give 0 KB output on conversion. Following is my code:

<?php
//set POST variables
$url = 'http://c.docverter.com/convert';
$fields = array('from' => 'html',
        'to' => 'pdf',
        'input_files[]' => "@/".realpath('samex.html').";type=text/x-markdown; charset=UTF-8",
        'other_files[]' => "@/".realpath('464087images.jpg')
        );

//open connection
$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); //needed so that the $result=curl_exec() output is the file and isn't just true/false

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

//write to file
$fp = fopen('uploads/result.pdf', 'w'); //make sure the directory markdown.md is in and the result.pdf will go to has proper permissions
fwrite($fp, $result);
fclose($fp);
?>

So is it an issue on my end or is it that API is down? You can find samexhtml here.

wisejoy7 commented 7 years ago

I tried another project but again got 0kb output with nothing in it. Please tell me what is the cause of the issue. Do we need any extra permissions enabled in PHP.

Thanks!

peterkeen commented 7 years ago

I'm almost 100% sure that it's something in your input. The API is working fine. You can confirm this by running this command on a linux or mac:

curl \
  http://c.docverter.com/convert \
  -F from=html \
  -F to=pdf \
  -F input_files[]=@<(echo hello) > out.pdf

out.pdf will be a PDF that just says "hello".