diff mbox series

[meta-oe,PATCHv2] libcupsfilters: fix the page count of PDF input

Message ID 20261121162432.2430934-1-f_l_k@t-online.de
State Under Review
Headers show
Series [meta-oe,PATCHv2] libcupsfilters: fix the page count of PDF input | expand

Commit Message

Markus Volk Nov. 21, 2026, 4:24 p.m. UTC
cfPDFPagesFP() copies the input into a temporary file and opens it with
PDFio without flushing the stdio buffer first, so small documents look
empty and the count fails. cfFilterGhostscript then stops every PDF job
with "Unexpected page count". Backport the upstream fix.

Tested by printing a PDF through CUPS to an IPP Everywhere printer.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 ...ror-pdfio-output-Missing-Root-object.patch | 28 +++++++++++++++++++
 .../cups/libcupsfilters_2.2.1.bb              |  1 +
 2 files changed, 29 insertions(+)
 create mode 100644 meta-oe/recipes-printing/cups/libcupsfilters/0002-Fix-printing-error-pdfio-output-Missing-Root-object.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-printing/cups/libcupsfilters/0002-Fix-printing-error-pdfio-output-Missing-Root-object.patch b/meta-oe/recipes-printing/cups/libcupsfilters/0002-Fix-printing-error-pdfio-output-Missing-Root-object.patch
new file mode 100644
index 0000000000..ee473b1367
--- /dev/null
+++ b/meta-oe/recipes-printing/cups/libcupsfilters/0002-Fix-printing-error-pdfio-output-Missing-Root-object.patch
@@ -0,0 +1,28 @@ 
+From e14bad406189a66bdeb40131112944bfb58ee0cc Mon Sep 17 00:00:00 2001
+From: szlt5 <117269245+szlt5@users.noreply.github.com>
+Date: Tue, 18 Aug 2026 16:04:19 +0800
+Subject: [PATCH] Fix printing error:  pdfio output "Missing Root object."
+ (#167)
+
+Upstream-Status: Backport [https://github.com/OpenPrinting/libcupsfilters/commit/e14bad406189a66bdeb40131112944bfb58ee0cc]
+Signed-off-by: Markus Volk <f_l_k@t-online.de>
+---
+ cupsfilters/pdf.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/cupsfilters/pdf.c b/cupsfilters/pdf.c
+index 1f714b203..3e4386091 100644
+--- a/cupsfilters/pdf.c
++++ b/cupsfilters/pdf.c
+@@ -165,6 +165,11 @@ cfPDFPagesFP(FILE *file) 	// I - File pointer of PDF
+     fwrite(buffer, 1, bytes_read, temp_fp);
+   }
+ 
++  // call fflush(temp_fp) to flush the stdio buffer; 
++  // otherwise pdfioFileOpen() may not see the complete contents of temp_filename because 
++  // some data may still be buffered and not yet written to the file.
++  fflush(temp_fp);  
++
+   // Open the temp file with pdfio
+   pdfio_file_t *pdf = pdfioFileOpen(temp_filename, NULL, NULL, NULL, NULL);
+ 
diff --git a/meta-oe/recipes-printing/cups/libcupsfilters_2.2.1.bb b/meta-oe/recipes-printing/cups/libcupsfilters_2.2.1.bb
index c1a887b3ec..957994b6d8 100644
--- a/meta-oe/recipes-printing/cups/libcupsfilters_2.2.1.bb
+++ b/meta-oe/recipes-printing/cups/libcupsfilters_2.2.1.bb
@@ -7,6 +7,7 @@  DEPENDS = "cups fontconfig libexif dbus lcms pdfio libpng jpeg tiff"
 
 SRC_URI = "https://github.com/OpenPrinting/${BPN}/releases/download/${PV}/${BP}.tar.xz \
            file://0001-Makefile.am-Only-generate-test_text_lorem.txt-for-ma.patch \
+           file://0002-Fix-printing-error-pdfio-output-Missing-Root-object.patch \
            "
 SRC_URI[sha256sum] = "0a22b849d5068c4c86b20fbb4192d3faa3dabcc9ee844c8fd73710ed821d4860"