我想在简历PDF中查看图片或制作副本。我已经尝试了一些来自互联网的代码,但它无法正常工作,或者图像必须像阴影或光晕一样有效,我需要一个可以获取图像/图片的PHP代码。例如,当我上传简历PDF时,我想从中获取2x2图片或复制它。
这些是我已经尝试过的代码,但它仅在图像有效时才有效。
require_once('lib/nusoap.php');
class extractImagesFromPdf {
public function toByteArray($file01)
{
if (!($fp = fopen($file01, "r")))
die ("can not open file: " . $file01) ;
$file = file_get_contents($file01);
$byteArr = str_split($file);
$length = sizeof($byteArr) ;
$data = "" ;
for($i = 0; $i < $length; $i++) {
$data .= base64_encode($byteArr[$i]);
}
return $data ;
}
function main ($subSerial, $fileContent)
{
$client = new nusoap_client("http://www.biclim.com/WS/BCService?wsdl", true);
$params[] = array('subSerial' => $subSerial,
'fileContent' => $fileContent
);
$result = $client->call("extractImagesFromPdf", $params);
$images = $result["extractImagesFromPdfResponse"];
print_r($images);
$i = 0;
$theDate = date("dmY_His") ;
foreach($images AS $image) {
$fp = fopen('d:/fileImages_Page' . $image['pageNumber'] . "_image" . $i . "_" . $theDate . "." . $image['imageType'], 'w');
print "\nExtracting Image " . $i . " in Page :" . $image['pageNumber'] ;
fwrite($fp, base64_decode($image['content']));
fclose ($fp);
$i = $i + 1;
}
}
}
$subSerial = "DEMO";
$extractImagesFromPdf = new extractImagesFromPdf() ;
$fileContent = $extractImagesFromPdf->toByteArray("D:/2.pdf") ;
$extractImagesFromPdf->main($subSerial, $fileContent);