J'ai un problème avec un script avec une ligne de commande .. Le script PHP ne continue ..ne continue pas après la ligne de commande
ont essayé d'appeler la ligne de commande directement par le mastic et sorties beaucoup d'erreurs mais retourne/se termine instantanément. Pourquoi ne retourne-t-il pas à PHP?
Il fonctionne très bien avec d'autres fichiers PDF, mais pas celui-ci
Code
$Cmd = new Command;
if($err = $Cmd->exec('/var/bin/poppler-0.51.0/utils/pdfimages -list /var/test.pdf')){
echo "ERR: $err\n";
}
echo "continue\n";
classe
class Command {
private $descriptorspec;
private $output = '';
private $process;
private $pipes = [];
public function __construct(){
$this->descriptorspec = [
0 => ['pipe', 'r'], // stdin
1 => ['pipe', 'w'], // stdout
2 => ['pipe', 'w'] // stderr
];
}
public function output(): string{
return $this->output;
}
public function close(){
foreach($this->pipes as $pipe){
if(is_resource($pipe)){
fclose($pipe);
}
}
proc_close($this->process);
}
public function exec(string $syntax){
$this->process = proc_open($syntax, $this->descriptorspec, $this->pipes);
fclose($this->pipes[0]);
$this->output = stream_get_contents($this->pipes[1]);
$stderr = stream_get_contents($this->pipes[2]);
$this->close();
return $stderr;
}
}
erreur
# /var/bin/poppler-0.51.0/utils/pdfimages -list /var/test.pdf
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 2154 303 rgb 3 8 jpeg yes [inline] 289 292 - -
Syntax Error (50560): Illegal character '>'
Syntax Error (50560): Unknown operator '<10><07><82>;w<ad><a2><b4>2r<1f><10><07><8f>~j<c4>Hq<cf>Z<86>'
Syntax Error (50568): Unknown operator '<0f><b5>X<8f><ae><d0>:<d7>DU<91><cb>'v'
Syntax Error (50568): Illegal character ')'
........
Syntax Error (66698): Illegal character <04> in hex string
Syntax Error (66699): Illegal character <ff> in hex string
Syntax Error (66699): Illegal character <c1> in hex string
Syntax Error (66705): Unknown operator '<9b>'
Syntax Error (66714): Illegal character ')'
Syntax Error (66714): Unknown operator '<bc>q<ff>'
Syntax Error (66720): Unknown operator '<05>6<f8><c2><fa><d7><c3>?<f8>'
Syntax Error (66741): Unknown operator '<df><ec><99><e1>-'
Syntax Error (66743): Unknown operator ']'
Syntax Error (66762): Unknown operator '<cc>'
Syntax Error: Unterminated string
Syntax Error: End of file inside array
Syntax Error: End of file inside array
Syntax Error: Leftover args in content stream
Votre commande vous demande-t-elle des informations de la part de l'utilisateur (vous)? –
@AdarshSojitra Non, il ne – clarkk
pas rapidement, je suis sûr que ce PDF est en train de mourir parce que le flux de contenu contient une image en ligne commencée par et «BI» suivi de données aléatoires et se termine par «EI». Les ingénieurs d'Adobe avaient une journée creuse quand ils ont conçu ces opérateurs, le problème étant que des situations surviennent où les données binaires contiennent aléatoirement «EI» et rendent le PDF incomparable. Certains outils peuvent gérer cela mieux, mais idéalement le producteur de cette image devrait éviter l'utilisation d'images en ligne. – dwarring