blob: 6feb57f20c33d7b9a318c39f0b48e53c77625bea [file] [log] [blame]
This patch modifies `gstoraster` to include the TotalPageCount field in
generated PWG-Raster content:
https://issuetracker.google.com/issues/172225466
--- a/filter/gstoraster.c
+++ b/filter/gstoraster.c
@@ -713,8 +713,13 @@ main (int argc, char **argv, char *envp[])
goto out;
}
+ /*
+ * Count pages.
+ * Later passed to GhostScript as cupsInteger[0].
+ */
+ int pages = 0;
if (doc_type == GS_DOC_TYPE_PDF) {
- int pages = pdf_pages(filename);
+ pages = pdf_pages(filename);
if (pages == 0) {
fprintf(stderr, "DEBUG: No pages left, outputting empty file.\n");
@@ -879,6 +884,13 @@ main (int argc, char **argv, char *envp[])
#endif /* HAVE_CUPS_1_7 */
}
+ /*
+ * cupsRasterParseIPPOptions() would populate the TotalPageCount field
+ * (h.cupsInteger[0]) if CUPS passed "job-impressions" to this filter.
+ * CUPS does not do so, so we set it manually here.
+ */
+ h.cupsInteger[0] = pages;
+
if ((h.HWResolution[0] == 100) && (h.HWResolution[1] == 100)) {
/* No "Resolution" option */
if (ppd && (attr = ppdFindAttr(ppd, "DefaultResolution", 0)) != NULL) {