PHP
PDF url
<?php
$api_key = "your_api_key";
$pdf_url = "https://example.com/your-pdf.pdf";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://v1.mlapi.co/pdf/pdf-to-text",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query(array('pdf_url' => $pdf_url, 'api_key' => $api_key)),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Upload PDF file
<?php
$api_key = "your_api_key";
$file_path = "path/to/your-pdf.pdf";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://v1.mlapi.co/pdf/pdf-to-text",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('file' => new CURLFile($file_path), 'api_key' => $api_key),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Last updated