PrintIPP just calls $ipp->setData($fileprint) and never tells CUPS what the file actually is, so the job arrives as application/octet-stream and CUPS treats ODT/PDF/PS as raw bytes - the ASCII garbage symptom the reporter sees. Map the file extension to a MIME and call $ipp->setMimeMediaType() when the extension is recognised. Unknown extensions fall through to the existing default, so the change is non-breaking. Signed-off-by: Dolicraft <contact@dolicraft.com> Co-authored-by: Dolicraft <contact@dolicraft.com>
This commit is contained in:
parent
163b18eac7
commit
f282afcd62
1 changed files with 17 additions and 0 deletions
|
|
@ -169,6 +169,23 @@ class printing_printipp extends PrintingDriver
|
|||
}
|
||||
$fileprint .= '/'.$file;
|
||||
$ipp->setData($fileprint);
|
||||
// Tell CUPS what we are sending so it picks the right filter chain (otherwise ODT/PDF arrive as raw and print as ASCII garbage).
|
||||
$extension = strtolower(pathinfo($fileprint, PATHINFO_EXTENSION));
|
||||
$mimebyext = array(
|
||||
'pdf' => 'application/pdf',
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'ps' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'txt' => 'text/plain',
|
||||
'png' => 'image/png',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
);
|
||||
if (isset($mimebyext[$extension])) {
|
||||
$ipp->setMimeMediaType($mimebyext[$extension]);
|
||||
}
|
||||
try {
|
||||
$ipp->printJob();
|
||||
} catch (Exception $e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue