Open giaza opened 2 years ago
I will have a close look later. But could you give some more details? E.g. how did you call the method, what was the expected command and what did you get instead?
I have found that this problem has been mentioned before in the issues. It happens in Windows OS because the PHP function escapeshellarg escapes the % character in Windows. There are workarounds. I used this function coding a drupal module like this:
$pdf = new Pdf( $dir . '/test.pdf');
$result = $pdf->burst($dir . "/output/pg_%04d.pdf");
if ($result === false)
{
$error = $pdf->getError();
return $error;
}
else
{
$output = "Operation completed";
}
The % character in the pattern is escaped and turned into a space.
Hmm, this is really tricky. escapeshellarg()
is neccessary to not get problems with special characters. And the reason why it's replacing %
with spaces on Windows is to prevent expansion of env vars (which could be a security concern).
We could add a second argument to burst()
to prevent escaping if required. I somehow don't like that idea but I see no better way (except forbidding people to use PHP under Windows as it's causing so much pain in this world 😛 ).
Probably related issue: #41
Hi, thank you for your amazing work. I used your library to split a large pdf into single pages. The method burst did not worked right away because the % character in the pattern was escaped and substituted with a white space in the processOptions function at line 213 of file command.php. So the output consisted of the last page only, as each page was overwriting the older. Changing the statement from $this->addArg('output', $filename, true); to $this->addArg('output', $filename, false); solved the problem. But probably It can cause other issues?