PDF.co Web API - PDF Information API - PHP - Get PDF Info From Uploaded File - ByteScout

PDF.co Web API – PDF Information API – PHP – Get PDF Info From Uploaded File

  • Home
  • /
  • Articles
  • /
  • PDF.co Web API – PDF Information API – PHP – Get PDF Info From Uploaded File

PDF.co Web API – PDF Information API – PHP – Get PDF Info From Uploaded File

get-pdf-info.php

[text]




PDF Information Results

Status code: ” . $status_code . “

“;
echo “

” . $result . “

“;
}
}
else
{
// Display CURL error
echo “Error: ” . curl_error($curl);
}
}
else
{
// Display service reported error
echo “

Status code: ” . $status_code . “

“;
echo “

” . $result . “

“;
}

curl_close($curl);
}
else
{
// Display CURL error
echo “Error: ” . curl_error($curl);
}

function ExtractInfo($apiKey, $uploadedFileUrl)
{
// Create URL
$url = “https://api.pdf.co/v1/pdf/info?url=” . $uploadedFileUrl;

// Create request
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array(“x-api-key: ” . $apiKey));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

// Execute request
$result = curl_exec($curl);

if (curl_errno($curl) == 0)
{
$status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status_code == 200)
{
$json = json_decode($result, true);

if ($json[“error”] == false)
{
$documentInfo = $json[“info”];

// Display the document info
echo “

Document Info:

“;
foreach ($documentInfo as $key => $value)
{
echo $key . ‘ = ‘ . $value . ‘
‘;
}
echo “

“;
}
else
{
// Display service reported error
echo “

Error: ” . $json[“message”] . “

“;
}
}
else
{
// Display request error
echo “

Status code: ” . $status_code . “

“;
echo “

” . $result . “

“;
}
}
else
{
// Display CURL error
echo “Error: ” . curl_error($curl);
}
}

?>



[/text]


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next