}
// Adjust header page size and margins according to the ppd file.
- ppdRasterMatchPPDSize(&header, ppd, margins, paperdimensions, NULL, NULL);
- if (pwgraster == 1)
- memset(margins, 0, sizeof(margins));
+ if (ppd) {
+ ppdRasterMatchPPDSize(&header, ppd, margins, paperdimensions, NULL, NULL);
+ if (pwgraster == 1)
+ memset(margins, 0, sizeof(margins));
+ } else {
+ for (int i = 0; i < 2; i ++)
+ paperdimensions[i] = header.PageSize[i];
+ if (header.cupsImagingBBox[3] > 0.0) {
+ /* Set margins if we have a bounding box defined ... */
+ if (pwgraster == 0) {
+ margins[0] = header.cupsImagingBBox[0];
+ margins[1] = header.cupsImagingBBox[1];
+ margins[2] = paperdimensions[0] - header.cupsImagingBBox[2];
+ margins[3] = paperdimensions[1] - header.cupsImagingBBox[3];
+ }
+ } else
+ /* ... otherwise use zero margins */
+ for (int i = 0; i < 4; i ++)
+ margins[i] = 0.0;
+ }
if (header.Duplex && (pgno & 1)) {
/* backside: change margin if needed */
#include "raster-private.h"
#include "ppd.h"
#include "debug-internal.h"
+#include <math.h>
/*
ppd_size_t *size, /* Current size */
*size_matched = NULL; /* Matched size */
int i = 0; /* Loop variable */
- char pageSizeRequested[64]; /* Requested PageSize */
+ char pageSizeRequested[64]; /* Requested PageSize */
strncpy(pageSizeRequested, header->cupsPageSizeName, 64); /* Prefer user-selected page size. */
- memset(dimensions, 0, sizeof(dimensions));
- memset(margins, 0, sizeof(margins));
+ memset(dimensions, 0, sizeof(double)*2);
+ memset(margins, 0, sizeof(double)*4);
size_matched = NULL;
for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
fabs(header->PageSize[0] - size->right + size->left) / size->width < 0.01 &&
(size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
{
- DEBUG_printf("DEBUG: Imageable area fit\n");
+ DEBUG_printf("Imageable area fit");
size_matched = size;
if (landscape) *landscape = 0;
if (image_fit) *image_fit = 1;
/*
* Standard size...
*/
- DEBUG_printf(("DEBUG: size = %s\n", size_matched->name));
+ DEBUG_printf(("PPD matched size = %s", size_matched->name));
size = size_matched;
dimensions[0] = size->width;
dimensions[1] = size->length;
fabs(header->PageSize[1] - size->right + size->left) / size->width < 0.01 &&
(size_matched == NULL || !strcasecmp(pageSizeRequested, size->name)))
{
- DEBUG_printf("DEBUG: Imageable area fit\n");
+ DEBUG_printf("Imageable area fit");
size_matched = size;
if (landscape) *landscape = 1;
if (image_fit) *image_fit = 1;
* Standard size in landscape orientation...
*/
size = size_matched;
- DEBUG_printf(("DEBUG: landscape size = %s\n", size->name));
+ DEBUG_printf(("landscape size = %s", size->name));
dimensions[0] = size->width;
dimensions[1] = size->length;
margins[0] = size->left;
/*
* Custom size...
*/
- DEBUG_printf("DEBUG: size = Custom\n");
+ DEBUG_printf("size = Custom");
for (i = 0; i < 2; i ++)
dimensions[i] = header->PageSize[i];
for (i = 0; i < 4; i ++)