From f282afcd62d93c1cc2d2aebeb40aa40e7d1f7f59 Mon Sep 17 00:00:00 2001 From: w3houde Date: Fri, 12 Jun 2026 00:05:03 +0200 Subject: [PATCH] Fix #37322 set IPP document-format from file extension in PrintIPP (#38706) 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 Co-authored-by: Dolicraft --- .../core/modules/printing/printipp.modules.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 17f57351398..8f49f53b184 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -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) {