Fix for pdfinfo changes in poppler-utils 0.48

PDF metadata querying was done with pdfinfo's "-meta" and "-l" options
at the same time, which was supported in poppler 0.26 but not in
poppler 0.48.

Upstream change: https://bugs.freedesktop.org/show_bug.cgi?id=96801

Local change is to run the two as separate commands, then send the
output together into the existing processing. Should work with older
poppler-utils on Jessie as well as current one on Stretch.

Bug: T117839
Bug: T193200
Change-Id: Ib4ee9cf12ac04304c576087727eff5dc521ae751
This commit is contained in:
Brion Vibber 2018-04-26 15:32:15 -07:00
parent 1b13edd761
commit 8c345b2784

View file

@ -119,17 +119,28 @@ class PdfImage {
global $wgPdfInfo, $wgPdftoText;
if ( $wgPdfInfo ) {
$cmd = [
// Note in poppler 0.26 the -meta and page data options worked together,
// but as of poppler 0.48 they must be queried separately.
// https://bugs.freedesktop.org/show_bug.cgi?id=96801
$cmdMeta = [
$wgPdfInfo,
'-enc', 'UTF-8', # Report metadata as UTF-8 text...
'-l', '9999999', # Report page sizes for all pages
'-meta', # Report XMP metadata
$this->mFilename,
];
$result = Shell::command( $cmd )
$resultMeta = Shell::command( $cmdMeta )
->execute();
$dump = $result->getStdout();
$cmdPages = [
$wgPdfInfo,
'-enc', 'UTF-8', # Report metadata as UTF-8 text...
'-l', '9999999', # Report page sizes for all pages
$this->mFilename,
];
$resultPages = Shell::command( $cmdPages )
->execute();
$dump = $resultMeta->getStdout() . $resultPages->getStdout();
$data = $this->convertDumpToArray( $dump );
} else {
$data = null;