media_source = _ppdCacheGetSource(pc, cupsGetOption("InputSlot", num_options, options));
media_type = _ppdCacheGetType(pc, cupsGetOption("MediaType", num_options, options));
- size = _ppdCacheGetSize(pc, keyword);
+ size = _ppdCacheGetSize(pc, keyword, /*ppd_size*/NULL);
if (media_col_sup && (size || media_source || media_type))
{
pwg_size_t * /* O - PWG size or NULL */
_ppdCacheGetSize(
_ppd_cache_t *pc, /* I - PPD cache and mapping data */
- const char *page_size) /* I - PPD PageSize */
+ const char *page_size, /* I - PPD PageSize */
+ ppd_size_t *ppd_size) /* I - PPD page size information */
{
int i; /* Looping var */
pwg_media_t *media; /* Media */
if (!pc || !page_size)
return (NULL);
- if (!_cups_strncasecmp(page_size, "Custom.", 7))
+ if (!_cups_strcasecmp(page_size, "Custom") || !_cups_strncasecmp(page_size, "Custom.", 7))
{
/*
* Custom size; size name can be one of the following:
char *ptr; /* Pointer into PageSize */
struct lconv *loc; /* Locale data */
- loc = localeconv();
- w = (float)_cupsStrScand(page_size + 7, &ptr, loc);
- if (!ptr || *ptr != 'x')
- return (NULL);
+ if (page_size[6])
+ {
+ loc = localeconv();
+ w = (float)_cupsStrScand(page_size + 7, &ptr, loc);
+ if (!ptr || *ptr != 'x')
+ return (NULL);
- l = (float)_cupsStrScand(ptr + 1, &ptr, loc);
- if (!ptr)
- return (NULL);
+ l = (float)_cupsStrScand(ptr + 1, &ptr, loc);
+ if (!ptr)
+ return (NULL);
- if (!_cups_strcasecmp(ptr, "in"))
- {
- w *= 2540.0;
- l *= 2540.0;
- }
- else if (!_cups_strcasecmp(ptr, "ft"))
- {
- w *= 12.0 * 2540.0;
- l *= 12.0 * 2540.0;
- }
- else if (!_cups_strcasecmp(ptr, "mm"))
- {
- w *= 100.0;
- l *= 100.0;
- }
- else if (!_cups_strcasecmp(ptr, "cm"))
- {
- w *= 1000.0;
- l *= 1000.0;
+ if (!_cups_strcasecmp(ptr, "in"))
+ {
+ w *= 2540.0;
+ l *= 2540.0;
+ }
+ else if (!_cups_strcasecmp(ptr, "ft"))
+ {
+ w *= 12.0 * 2540.0;
+ l *= 12.0 * 2540.0;
+ }
+ else if (!_cups_strcasecmp(ptr, "mm"))
+ {
+ w *= 100.0;
+ l *= 100.0;
+ }
+ else if (!_cups_strcasecmp(ptr, "cm"))
+ {
+ w *= 1000.0;
+ l *= 1000.0;
+ }
+ else if (!_cups_strcasecmp(ptr, "m"))
+ {
+ w *= 100000.0;
+ l *= 100000.0;
+ }
+ else
+ {
+ w *= 2540.0 / 72.0;
+ l *= 2540.0 / 72.0;
+ }
}
- else if (!_cups_strcasecmp(ptr, "m"))
+ else if (ppd_size)
{
- w *= 100000.0;
- l *= 100000.0;
+ w = ppd_size->width * 2540.0 / 72.0;
+ l = ppd_size->length * 2540.0 / 72.0;
}
else
{
- w *= 2540.0 / 72.0;
- l *= 2540.0 / 72.0;
+ // No custom size information...
+ return (NULL);
}
- pc->custom_size.width = (int)w;
- pc->custom_size.length = (int)l;
+ pc->custom_size.map.ppd = (char *)page_size;
+ pc->custom_size.width = (int)w;
+ pc->custom_size.length = (int)l;
+
+ if ((media = pwgMediaForSize((int)w, (int)l)) != NULL)
+ pc->custom_size.map.pwg = (char *)media->pwg;
return (&(pc->custom_size));
}
*/
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
+ {
if (!_cups_strcasecmp(page_size, size->map.ppd) ||
!_cups_strcasecmp(page_size, size->map.pwg))
return (size);
+ }
/*
* Look up standard sizes...
*/
if ((media = pwgMediaForPPD(page_size)) == NULL)
+ {
if ((media = pwgMediaForLegacy(page_size)) == NULL)
media = pwgMediaForPWG(page_size);
+ }
if (media)
{
- pc->custom_size.width = media->width;
- pc->custom_size.length = media->length;
+ pc->custom_size.map.ppd = (char *)page_size;
+ pc->custom_size.map.pwg = (char *)media->pwg;
+ pc->custom_size.width = media->width;
+ pc->custom_size.length = media->length;
return (&(pc->custom_size));
}
extern const char *_ppdCacheGetMediaType(_ppd_cache_t *pc, ipp_t *job, const char *keyword) _CUPS_PRIVATE;
extern const char *_ppdCacheGetOutputBin(_ppd_cache_t *pc, const char *keyword) _CUPS_PRIVATE;
extern const char *_ppdCacheGetPageSize(_ppd_cache_t *pc, ipp_t *job, const char *keyword, int *exact) _CUPS_PRIVATE;
-extern pwg_size_t *_ppdCacheGetSize(_ppd_cache_t *pc, const char *page_size) _CUPS_PRIVATE;
+extern pwg_size_t *_ppdCacheGetSize(_ppd_cache_t *pc, const char *page_size, ppd_size_t *ppd_size) _CUPS_PRIVATE;
extern const char *_ppdCacheGetSource(_ppd_cache_t *pc, const char *input_slot) _CUPS_PRIVATE;
extern const char *_ppdCacheGetType(_ppd_cache_t *pc, const char *media_type) _CUPS_PRIVATE;
extern int _ppdCacheWriteFile(_ppd_cache_t *pc, const char *filename, ipp_t *attrs) _CUPS_PRIVATE;
/*
* PPD test program for CUPS.
*
- * Copyright © 2020-2024 by OpenPrinting.
+ * Copyright © 2020-2025 by OpenPrinting.
* Copyright © 2007-2018 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
*
* information.
*/
-/*
- * Include necessary headers...
- */
-
#undef _CUPS_NO_DEPRECATED
#include "cups-private.h"
#include "ppd-private.h"
ppd_option_t *option; /* Option */
ppd_coption_t *coption; /* Custom option */
ppd_cparam_t *cparam; /* Custom parameter */
+ ppd_size_t *size; /* Default paper size */
ppd_const_t *c; /* UIConstraints */
char lang[255], /* LANG environment variable */
lc_all[255], /* LC_ALL environment variable */
puts("\nPPD Cache:");
if ((pc = _ppdCacheCreateWithPPD(NULL, ppd)) == NULL)
+ {
printf(" Unable to create: %s\n", cupsGetErrorString());
+ }
else
{
_ppdCacheWriteFile(pc, "t.cache", NULL);
puts(" Wrote t.cache.");
}
+
+ if ((size = ppdPageSize(ppd, NULL)) != NULL)
+ {
+ pwg_size_t *pwg; /* PWG media size */
+
+ pwg = _ppdCacheGetSize(pc, size->name, size);
+
+ printf(" media-default: %s\n", pwg ? pwg->map.pwg : "unknown");
+ }
}
if (!strncmp(argv[1], "-d", 2))
/*
* CUPS raster to PWG raster format filter for CUPS.
*
- * Copyright © 2020-2024 by OpenPrinting.
+ * Copyright © 2020-2025 by OpenPrinting.
* Copyright © 2011, 2014-2017 Apple Inc.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
-/*
- * Include necessary headers...
- */
-
#include <cups/cups-private.h>
#include <cups/ppd-private.h>
#include <cups/raster.h>
}
}
- if (inheader.cupsPageSizeName[0] && (pwg_size = _ppdCacheGetSize(cache, inheader.cupsPageSizeName)) != NULL && pwg_size->map.pwg)
+ if (inheader.cupsPageSizeName[0] && (pwg_size = _ppdCacheGetSize(cache, inheader.cupsPageSizeName, /*ppd_size*/NULL)) != NULL && pwg_size->map.pwg)
{
cupsCopyString(outheader.cupsPageSizeName, pwg_size->map.pwg,
sizeof(outheader.cupsPageSizeName));