From 31f9a0320656414390d84e3a7c074626f57872d1 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Mon, 23 Dec 2024 00:46:03 +0100 Subject: [PATCH] Do not default to input page size Letter when job format defines page sizes Not only for the PostScript-to-PDF case of PR #69/Issue #68 but generally for input formats which define the absolute size dimensions for each page (PostScript, PDF, CUPS/PWG/Apple Raster) we do not default to US Letter if no input page size is given. --- cupsfilters/raster.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c index 316c86cc7..93975d3d2 100644 --- a/cupsfilters/raster.c +++ b/cupsfilters/raster.c @@ -374,12 +374,21 @@ cfRasterPrepareHeader(cups_page_header_t *h, // I - Raster header else if (size_name_buf[0]) _strlcpy(h->cupsPageSizeName, size_name_buf, sizeof(h->cupsPageSizeName)); - if (data->printer_attrs != NULL || - data->job_attrs != NULL || - final_outformat != CF_FILTER_OUT_FORMAT_PDF || - data->content_type == NULL || - strcmp(data->content_type, "application/postscript")) + log(ld, CF_LOGLEVEL_DEBUG, "Format of the input document: %s", data->content_type); + if (data->content_type == NULL || + (strcmp(data->content_type, "application/postscript") && + strcmp(data->content_type, "application/vnd.cups-postscript") && + strcmp(data->content_type, "application/pdf") && + strcmp(data->content_type, "application/vnd.cups-pdf") && + strcmp(data->content_type, "application/vnd.cups-raster") && + strcmp(data->content_type, "image/pwg-raster") && + strcmp(data->content_type, "image/urf"))) { + // The input format of the document does not define the sizes of the + // input pages in absolute dimensions, so if no output page size + // is defined, fall back to US Letter + log(ld, CF_LOGLEVEL_DEBUG, + "Document's input format does not provide absolute size dimensions for each page, falling back to US Letter if no output page size is provided."); cfSetPageDimensionsToDefault(&(dimensions[0]), &(dimensions[1]), &(margins[0]), &(margins[1]), &(margins[2]), &(margins[3]), @@ -388,7 +397,7 @@ cfRasterPrepareHeader(cups_page_header_t *h, // I - Raster header else { log(ld, CF_LOGLEVEL_DEBUG, - "Postscript to PDF and no attributes: not setting page size."); + "Document's input format provides absolute size dimensions for each page, using these if no output page size is provided."); } if (!cupsrasterheader)