Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
32a35927
Commit
32a35927
authored
Nov 28, 2019
by
Carsten Rose
Browse files
Fixes #9670. If `qpdf` fails to decrypt a PDF, try `gs`.
parent
36e1a8ee
Pipeline
#2817
passed with stages
in 2 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Documentation/Manual.rst
View file @
32a35927
...
...
@@ -52,6 +52,7 @@ The following features are only tested / supported on linux hosts:
* HTML to PDF conversion - command `wkhtmltopdf`.
* Concatenation of PDF files - command `pdfunite`.
* PDF decrypt (used for merge with pdfunite) - command `qpdf`.
* PDF decrypt (used for merge with pdfunite) - command `gs` - in case `qpdf` is not successful.
* Mime type detection for uploads - command `file`.
...
...
@@ -67,12 +68,12 @@ To normalize UTF8 input, *php-intl* package is needed by
* normalizer::normalize()
For the `download`_ function, the programs `pdfunite`, `qpdf` and `file` are necessary to concatenate PDF files.
For the `download`_ function, the programs `pdfunite`, `qpdf`
, `gs`
and `file` are necessary to concatenate PDF files.
Preparation for Ubuntu::
sudo apt install php-intl
sudo apt install poppler-utils libxrender1 file pdf2svg pdfunite qpdf # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf), PDF split
sudo apt install poppler-utils libxrender1 file pdf2svg pdfunite qpdf
ghostscript
# for file upload, PDF and 'HTML to PDF' (wkhtmltopdf), PDF split
sudo apt install inkscape imagemagick # to render thumbnails
.. _wkhtml:
...
...
extension/Classes/Core/Report/Download.php
View file @
32a35927
...
...
@@ -174,12 +174,12 @@ class Download {
$last
=
''
;
$rcOutput
=
'-'
;
// Try to merge the PDFs as long as a problematic PDF has been repaired.
// Try to merge the PDFs as long as a problematic PDF has been repaired.
Check this by comparing the last and the current output.
while
(
$last
!=
$rcOutput
)
{
$last
=
$rcOutput
;
// Remember last
// Merge
// Merge
:
exec
(
$cmd
,
$rcOutput
,
$rc
);
if
(
$rc
==
0
)
{
...
...
@@ -200,15 +200,24 @@ class Download {
HelperFile
::
copy
(
$file
,
$backup
);
}
// Try 1: via 'qpdf --decrypt'
$cmdQpdf
=
"qpdf --decrypt '
$backup
' '
$file
' 2>&1"
;
// Try to decrypt file
exec
(
$cmdQpdf
,
$outputQpdf
,
$rcQpdf
);
if
(
$rcQpdf
!=
0
)
{
// qpdf failed: restore origfile in case the $file has been destroyed.
HelperFile
::
copy
(
$backup
,
$file
);
throw
new
\
DownloadException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
"Failed to decrypt PDF"
,
ERROR_MESSAGE_TO_DEVELOPER
=>
"CMD: "
.
$cmdQpdf
.
"<br>RC:
$rc
<br>Output: "
.
implode
(
"<br>"
,
$outputQpdf
)])
,
ERROR_DOWNLOAD_MERGE_FAILED
);
// Try 2: via 'gs -sDEVICE=pdfwrite'
$cmdGs
=
"gs -sDEVICE=pdfwrite -dNOPAUSE -sOutputFile=
\"
$file
\"
--
\"
$backup
\"
"
;
exec
(
$cmdGs
,
$outputGs
,
$rcGs
);
if
(
$rcGs
!=
0
)
{
// qpdf failed: restore origfile in case the $file has been destroyed.
HelperFile
::
copy
(
$backup
,
$file
);
throw
new
\
DownloadException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
"Failed to decrypt PDF"
,
ERROR_MESSAGE_TO_DEVELOPER
=>
"CMD1: "
.
$cmdQpdf
.
"<br>RC:
$rcQpdf
<br>Output: "
.
implode
(
"<br>"
,
$outputQpdf
)
.
'<br>'
.
"CMD2: "
.
$cmdGs
.
"<br>RC:
$rcGs
<br>Output: "
.
implode
(
"<br>"
,
$outputGs
)])
,
ERROR_DOWNLOAD_MERGE_FAILED
);
}
}
}
}
else
{
...
...
@@ -217,6 +226,7 @@ class Download {
,
ERROR_DOWNLOAD_MERGE_FAILED
);
}
}
return
$rc
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment