PHP를 사용하여 PDF 파일에서 메타 데이터 (XMP) 정보에 액세스하려면 어떻게합니까? 나는 파일의 높이와 너비가 필요하다.PHP를 사용하여 PDF 파일에서 메타 데이터 정보에 액세스하려면 어떻게합니까?
답변
Zend Framework, 특히 Zend_Pdf 구성 요소를 살펴볼 수 있습니다. 자신의 매뉴얼 페이지에서
:
$pdf = Zend_Pdf::load($pdfPath);
echo $pdf->properties['Title'] . "\n";
echo $pdf->properties['Author'] . "\n";
$pdf->properties['Title'] = 'New Title.';
$pdf->save($pdfPath);
HTH
고마워,하지만 난 여분의 라이브러리없이 해결책을 찾고 있는데. –
방금 폭과 높이를 원하는 경우,이 점에서 당신에게 높이와 폭을 줄 것이다
<?php
$pdffile = "filename.pdf";
$pdfinfo = shell_exec("pdfinfo ".$pdffile);
// find height and width
preg_match('/Page size:\s+([0-9]{0,5}\.?[0-9]{0,3}) x ([0-9]{0,5}\.?[0-9]{0,3})/', $pdfinfo,$heightandwidth);
$width = $heightandwidth[1];
$height = $heightandwidth[2];
?>
사용합니다. 그러면 원하는 단위로 변환 할 수있는 간단한 수학을 할 수 있습니다.
좋은데, 나에게 일하지 마라. –
hum ... pdfinfo는 도서관에서 명령이다. :( –
ImageMagick understands PDF's 및 Imagick::identifyImage()
은 많은 정보가있는 배열을 반환합니다.
이 조각 :
$img = new Imagick('test.pdf');
var_dump($img->identifyImage());
이 렌더링 생성 :
array(9) {
["imageName"]=>
string(9) "/test.pdf"
["format"]=>
string(30) "PDF (Portable Document Format)"
["geometry"]=>
array(2) {
["width"]=>
int(596)
["height"]=>
int(843)
}
["resolution"]=>
array(2) {
["x"]=>
float(72)
["y"]=>
float(72)
}
["units"]=>
string(9) "Undefined"
["type"]=>
string(14) "TrueColorMatte"
["colorSpace"]=>
string(3) "RGB"
["compression"]=>
string(9) "Undefined"
["fileSize"]=>
string(7) "37.6KBB"
}
는 [이 답변에] 봐 (http://stackoverflow.com/questions/9622357/php-get-height pdf-file-proprieties)에서 질문과 대답을 통해 필요한 정보를 얻을 수 있습니다. – David