]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Add necessary headers
authorVikrant <vikrantmalik051@gmail.com>
Thu, 16 Jul 2020 10:16:11 +0000 (15:46 +0530)
committerVikrant <vikrantmalik051@gmail.com>
Thu, 16 Jul 2020 11:13:55 +0000 (16:43 +0530)
filter/pclmtoraster.cxx
filter/pdftoraster.cxx
ppd/raster-interpret.c

index 5d0af4f49c2b3fd18679f827abbc37073442273b..131fa526a9c47fb6d72c2dc23ea2b301f69b1261 100644 (file)
@@ -618,9 +618,26 @@ static void outPage(cups_raster_t *raster, QPDFObjectHandle page, int pgno) {
   }
 
   // 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 */
index 9e617619ac64e7434ee1e0267983725b2c71a0ae..22b4f3c9e4ab9c283e0ec2b9b9ae4625b44c5c0a 100644 (file)
@@ -1372,8 +1372,6 @@ static void outPage(poppler::document *doc, int pageNo,
   int rotate = 0;
   double paperdimensions[2], /* Physical size of the paper */
     margins[4];        /* Physical margins of print */
-  ppd_size_t *size;            /* Page size */
-  ppd_size_t *size_matched = NULL;
   double l, swap;
   int imageable_area_fit = 0;
   int i;
index 1b3144de520aee4d1fd216490c06169b1dba29e2..4b49425b2a1694dc0cd10140b03da52a7b285799 100644 (file)
@@ -15,6 +15,7 @@
 #include "raster-private.h"
 #include "ppd.h"
 #include "debug-internal.h"
+#include <math.h>
 
 
 /*
@@ -511,11 +512,11 @@ ppdRasterMatchPPDSize(
   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 ++)
@@ -541,7 +542,7 @@ ppdRasterMatchPPDSize(
        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;
@@ -553,7 +554,7 @@ ppdRasterMatchPPDSize(
     /*
     * 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;
@@ -589,7 +590,7 @@ ppdRasterMatchPPDSize(
        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;
@@ -603,7 +604,7 @@ ppdRasterMatchPPDSize(
      * 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;
@@ -617,7 +618,7 @@ ppdRasterMatchPPDSize(
     /*
      * 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 ++)