php - 在我的 PHP 代码中从上传的 PDF 元数据文件中获取页面大小
问题描述
这里我使用了一个 PDF 解析器 PHP 库:
<?php
include 'vendor/autoload.php';
// Parse PDF file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile('ss.pdf');
// Retrieve all details from the PDF file.
$details = $pdf->getDetails();
var_dump($details);
// Loop over each property to extract values (string or array).
foreach ($details as $property => $value) {
if (is_array($value)) {
$value = implode(', ', $value);
}
echo $property . ' => ' . $value .' -|- ';
echo "\r";
}
但它只给了我这个结果:
'Author' => string 'Adrien LORENZI' (length=14)
'Creator' => string 'Microsoft® Word 2010' (length=21)
'CreationDate' => string '2019-12-18T11:42:02+01:00' (length=25)
'ModDate' => string '2019-12-18T11:42:02+01:00' (length=25)
'Producer' => string 'Microsoft® Word 2010' (length=21)
'Pages' => int 6
虽然我试图从https://www.pdfyeah.com/view-pdf-metadata/获取元数据,但它给了我这个结果:
Author: Adrien LORENZI
Creator: Microsoft® Word 2010
Producer: Microsoft® Word 2010
CreationDate: Wed Dec 18 11:42:02 2019 CET
ModDate: Wed Dec 18 11:42:02 2019 CET
Tagged: yes
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 6
Encrypted: no
Page size: 595.32 x 841.92 pts (A4)
Page rot: 0
File size: 436449 bytes
Optimized: no
PDF version: 1.5
Page size: 595.32 x 841.92 pts (A4)
这就是我想要的元数据。如何使用 PHP 从元数据中找到它?
解决方案
推荐阅读
- vue.js - VueJS v-validate方法在传递到组件后无法操作
- python - python 多进程分叉如何在资源共享方面起作用
- php - 如何使用 curl nad simple_html_dom 打印页面的源代码
- python - 从另一个 python 脚本运行 python 脚本时找不到模块
- node.js - NodeJS Sequelize model options.timestamp 在 MSSQL 中生成额外的列
- javascript - 使用 backstretch 更改 HTML
- javascript - Javascript 三元布尔简写
- android - 是否存在与 TapGestureRecognizer 对象的 Tapped 事件等效的 UnTapped 事件?
- docker - 如何在我的本地浏览器中查看 docker 浏览器应用程序?
- graph - 在子集中找到最大距离