Skip to content

Commit

Permalink
Do not default to input page size Letter when job format defines page…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
tillkamppeter committed Dec 22, 2024
1 parent eb2d498 commit 31f9a03
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions cupsfilters/raster.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand All @@ -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)
Expand Down

0 comments on commit 31f9a03

Please sign in to comment.