我有一个PDF文件。我想获取它的高度和宽度(单位为毫米)。
因此,我执行了pdfinfo命令,并得到以下结果:
没关系,因为我有三个数字点三个数字(552.744 x 708.643)。 但是,我不知道为什么,一些PDF文件中有这些信息:
我测试了这个:
(注:该内容为关于页面尺寸的技术描述)
因此,我执行了pdfinfo命令,并得到以下结果:
我有一个提取信息的脚本:创建者:Adobe InDesign CS5(7.0.3)生产者:Acrobat Distiller 9.4.2(Macintosh)创建日期:2012年1月30日星期一15:48:43修改日期:2012年2月10日星期五10:35:05标记:否页数:34加密:否页面大小:552.744 x 708.643点文件大小:80724791字节优化:是PDF版本:1.3
<?php
$output = shell_exec("pdfinfo ".$pdflivrelink);
$data = explode("\n", $output); //puts it into an array
for($c=0; $c < count($data); $c++) {
if(stristr($data[$c],"Pages") == true) {
$pagesnumber = trim(substr($data[$c],6));
}
if(stristr($data[$c],"Page size") == true) {
$pagesize_H = height_pdf(trim(substr($data[$c],9)));
}
if(stristr($data[$c],"Page size") == true) {
$pagesize_L = width_pdf(trim(substr($data[$c],9)));
}
}
function height_pdf($size){
$hauteur = round(substr($size,7,7)/2.83);
return $hauteur;
}
function width_pdf($size){
$largeur = round(substr($size,17,7)/2.83);
return $largeur;
} ?>
没关系,因为我有三个数字点三个数字(552.744 x 708.643)。 但是,我不知道为什么,一些PDF文件中有这些信息:
425.2 x 538.582 : 所以我的脚本不能工作! 你能帮助我吗?非常感谢!Creator: pdftk 1.41 - www.pdftk.com Producer: iText 2.1.5 (by lowagie.com) CreationDate: Mon Feb 27 13:18:23 2012 ModDate: Mon Feb 27 16:26:12 2012 Tagged: no Pages: 36 Encrypted: no Page size: 425.2 x 538.582 pts File size: 5097597 bytes Optimized: yes PDF version: 1.6
我测试了这个:
$output = shell_exec("pdfinfo ".$pdflivrelink);
$data = explode("\n", $output); //puts it into an array
for($c=0; $c < count($data); $c++) {
if(stristr($data[$c],"Pages") == true) {
$pagesnumber = trim(substr($data[$c],6));
}
if(stristr($data[$c],"Page size") == true) {
echo $data[$c];
preg_match('/Page size: ([0-9]*\.?[0-9]?) x ([0-9]*\.?[0-9]?)/', $data[$c], $matchess);
$width = round($matchess[1]/2.83);
$height = round($matchess[2]/2.83);
}
}
echo "width = $width<br>height = $height";
IT结果:
页面大小:425.2 x 538.582 点,宽度 = 0,高度 = 0
(注:该内容为关于页面尺寸的技术描述)
2.83 = 72 / 25.4
- LF00