PHP code example of csoellinger / xpdf-cli-pdfinfo
1. Go to this page and download the library: Download csoellinger/xpdf-cli-pdfinfo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
csoellinger / xpdf-cli-pdfinfo example snippets
use XpdfCliTools\PdfInfo\PdfInfo;
use XpdfCliTools\PdfInfo\Model\PdfInfoModel;
$pdfInfo = new PdfInfo();
// Optionally set a custom path to pdfinfo binary file:
// $pdfInfo = new PdfInfo('<Path-To-Binary>');
/** @var PdfInfoModel $info */
$info = $pdfInfo->exec('<Path-To-Pdf>.pdf');
// If you have a passwort protected pdf file:
// $info = $pdfInfo->exec('<Path-To-Pdf>.pdf', 'OwnerPassword');
// $info = $pdfInfo->exec('<Path-To-Pdf>.pdf', null, 'UserPassword');
// Access the pdf informations
echo $info->Creator; // Creator
echo $info->Producer; // Producer
echo $info->CreationDate; // Creation date
echo $info->ModDate; // Modification date
echo $info->Tagged; // Tagged (true/false)
echo $info->Form; // Form(s)
echo $info->Pages; // Number of pages
echo $info->PageSize->Width; // Page width as points
echo $info->PageSize->Height; // Page height as points
echo $info->PageSize->Format; // Page format (if found)
echo $info->PageSize->RotatedDegrees; // Degrees if rotated
echo $info->PageSize->raw; // Raw shell output for page size
// Available boxes: MediaBox, CropBox, BleedBox, TrimBox, ArtBox
echo $info->MediaBox->X; // X coordinate
echo $info->MediaBox->Y; // Y coordinate
echo $info->MediaBox->Width; // Box width as points
echo $info->MediaBox->Height; // Box height as points
echo $info->MediaBox->raw; // Raw shell output for box
echo $info->FileSize->Bytes; // File size in bytes
echo $info->FileSize->raw; // Raw shell output for file size
echo $info->Encrypted; // Encrypted (true/false)
echo $info->Optimized; // Optimized (true/false)
echo $info->PDFVersion; // Version
echo $info->raw; // Raw shell output from pdfinfo
// Get page size as millimeter:
echo $info->PageSize->Width / PdfInfo::MM_TO_PTS; // = Convert points to millimeter
echo $info->PageSize->Height / PdfInfo::MM_TO_PTS; // = Convert points to millimeter
php -S localhost:8000
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.