Ghostscript's "cups" output
device.*/
+
extern int bannertopdf(int inputfd,
int outputfd,
int inputseekable,
filter_data_t *data,
void *parameters);
+/* Parameters: filter_out_format_t* Ouput format: CUPS Raster, PWG
+ Raster, Apple Raster, PCLM
+ Note: On the Apple Raster, PWG Raster, and PCLm selection the
+ output is actually CUPS Raster but information about available
+ color spaces and depths is taken from the urf-supported or
+ pwg-raster-document-type-supported printer IPP attributes or
+ appropriate PPD file attributes. This mode is for further
+ processing with rastertopwg or rastertopclm. This can change in the
+ future when we add Apple Raster and PWG Raster output support to
+ this filter function. */
+
+
extern int mupdftoraster(int inputfd,
- int outputfd,
- int inputseekable,
- filter_data_t *data,
- void *parameters);
+ int outputfd,
+ int inputseekable,
+ filter_data_t *data,
+ void *parameters);
extern int pclmtoraster(int inputfd,
int outputfd,
void* parameters);
/* Parameters: filter_out_format_t*
- Ouput format: CUPS Raster or PWG Raster */
+ Ouput format: CUPS Raster, PWG Raster, Apple Raster, PCLm
+ Note: With Apple Raster or PCLm selections the output is actually
+ CUPS Raster but information about available color spaces and depths
+ is taken from the urf-supported printer IPP attribute or the
+ appropriate PPD file attribute (PCLM is always sRGB 8-bit). These
+ modes are for further processing with rastertopwg or
+ rastertopclm. This can change in the future when we add Apple
+ Raster output support to this filter. */
extern int pstops(int inputfd,
Data directory (fonts, charsets), charset, content type (for prettyprint),
classification (for overprint/watermark) */
-extern int texttotext(int inputfd,
- int outputfd,
- int inputseekable,
- filter_data_t *data,
- void *parameters);
-extern int universal(int inputfd,
+extern int texttotext(int inputfd,
int outputfd,
int inputseekable,
filter_data_t *data,
void *parameters);
-/*
- Parameters: filter_input_output_format_t
- Contains : Input_type : CONTENT_TYPE environment variable
- Output type : FINAL_CONTENT TYPE environment variable */
-
+extern int universal(int inputfd,
+ int outputfd,
+ int inputseekable,
+ filter_data_t *data,
+ void *parameters);
+
+/* Parameters: filter_input_output_format_t
+ Contains : Input_type : CONTENT_TYPE environment variable
+ Output type : FINAL_CONTENT TYPE environment variable */
+
+
extern void filterSetCommonOptions(ppd_file_t *ppd,
int num_options,
cups_option_t *options,
FILE *fp = NULL;
GsDocType doc_type;
gs_page_header h;
- cups_cspace_t cspace;
+ cups_cspace_t cspace = -1;
int bytes;
int fd;
int cm_disabled;
}
cspace = icc_profile ? CUPS_CSPACE_RGB : -1;
- cupsRasterPrepareHeader(&h, data, outformat, &cspace);
+ cupsRasterPrepareHeader(&h, data, outformat,
+ (outformat != OUTPUT_FORMAT_APPLE_RASTER ?
+ outformat : OUTPUT_FORMAT_CUPS_RASTER),
+ &cspace);
/* Special Ghostscript options for raster-only PDF output */
#include <cupsfilters/image.h>
#include <cupsfilters/ppdgenerator.h>
#include <cupsfilters/raster.h>
+#include <cupsfilters/image-private.h>
#include <math.h>
#include <ctype.h>
#include <errno.h>
}
else {
float final_w=w,final_h=h;
- if(final_w>pw)
- {
- final_w = pw;
- }
- if(final_h>ph)
+ if (w > pw * doc.img->xppi / 72.0)
+ final_w = pw * doc.img->xppi / 72.0;
+ if (h > ph * doc.img->yppi / 72.0)
+ final_h = ph * doc.img->yppi / 72.0;
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+doc.XPosition)*posw;
+ posh = (1-doc.YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(doc.img,posw,posh,final_w,final_h);
+ cupsImageClose(doc.img);
+ doc.img = img2;
+ if(flag==4)
{
- final_h = ph;
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_w * 72.0 / doc.img->xppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_w * 72.0 / doc.img->xppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_h * 72.0 / doc.img->yppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_h * 72.0 / doc.img->yppi;
}
- if((fabs(final_w-w)>0.5*w)||(fabs(final_h-h)>0.5*h))
+ else
{
- if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
- "imagetopdf: Ignoring crop-to-fit option!");
- cropfit=0;
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_h * 72.0 / doc.img->yppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_h * 72.0 / doc.img->yppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_w * 72.0 / doc.img->xppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_w * 72.0 / doc.img->xppi;
}
- else{
- float posw=(w-final_w)/2,posh=(h-final_h)/2;
- posw = (1+doc.XPosition)*posw;
- posh = (1-doc.YPosition)*posh;
- cups_image_t *img2 = cupsImageCrop(doc.img,posw,posh,final_w,final_h);
- cupsImageClose(doc.img);
- doc.img = img2;
- if(flag==4)
- {
- doc.PageBottom+=(doc.PageTop-doc.PageBottom-final_w)/2;
- doc.PageTop = doc.PageBottom+final_w;
- doc.PageLeft +=(doc.PageRight-doc.PageLeft-final_h)/2;
- doc.PageRight = doc.PageLeft+final_h;
- }
- else{
- doc.PageBottom+=(doc.PageTop-doc.PageBottom-final_h)/2;
- doc.PageTop = doc.PageBottom+final_h;
- doc.PageLeft +=(doc.PageRight-doc.PageLeft-final_w)/2;
- doc.PageRight = doc.PageLeft+final_w;
- }
- if(doc.PageBottom<0) doc.PageBottom = 0;
- if(doc.PageLeft<0) doc.PageLeft = 0;
- }
+ if(doc.PageBottom<0) doc.PageBottom = 0;
+ if(doc.PageLeft<0) doc.PageLeft = 0;
}
}
#include <cupsfilters/filter.h>
#include <cupsfilters/image.h>
#include <cupsfilters/raster.h>
+#include <cupsfilters/image-private.h>
#include <math.h>
#include <signal.h>
#include <string.h>
else
{
float final_w = w, final_h = h;
- if(final_w > pw)
- final_w = pw;
- if(final_h > ph)
- final_h = ph;
- if ((fabs(final_w - w) > 0.5 * w) || (fabs(final_h - h) > 0.5 * h))
+ if (w > pw * img->xppi / 72.0)
+ final_w = pw * img->xppi / 72.0;
+ if (h > ph * img->yppi / 72.0)
+ final_h = ph * img->yppi / 72.0;
+ float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
+ posw = (1 + XPosition) * posw;
+ posh = (1 - YPosition) * posh;
+ cups_image_t *img2 = cupsImageCrop(img, posw, posh, final_w, final_h);
+ cupsImageClose(img);
+ img = img2;
+ if (flag == 4)
{
- if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
- "imagetops: Ignoring crop-to-fit option!");
- cropfit = 0;
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_w * 72.0 / img->xppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_w * 72.0 / img->xppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_h * 72.0 / img->yppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_h * 72.0 / img->yppi;
}
else
{
- float posw = (w - final_w) / 2, posh = (h - final_h) / 2;
- posw = (1 + XPosition) * posw;
- posh = (1 - YPosition) * posh;
- cups_image_t *img2 = cupsImageCrop(img, posw, posh, final_w, final_h);
- cupsImageClose(img);
- img = img2;
- if (flag == 4)
- {
- doc.PageBottom += (doc.PageTop - doc.PageBottom - final_w) / 2;
- doc.PageTop = doc.PageBottom + final_w;
- doc.PageLeft += (doc.PageRight - doc.PageLeft - final_h) / 2;
- doc.PageRight = doc.PageLeft + final_h;
- }
- else
- {
- doc.PageBottom += (doc.PageTop - doc.PageBottom - final_h) / 2;
- doc.PageTop = doc.PageBottom + final_h;
- doc.PageLeft += (doc.PageRight - doc.PageLeft - final_w) / 2;
- doc.PageRight = doc.PageLeft + final_w;
- }
- if (doc.PageBottom < 0) doc.PageBottom = 0;
- if (doc.PageLeft < 0) doc.PageLeft = 0;
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_h * 72.0 / img->yppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_h * 72.0 / img->yppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_w * 72.0 / img->xppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_w * 72.0 / img->xppi;
}
+ if (doc.PageBottom < 0) doc.PageBottom = 0;
+ if (doc.PageLeft < 0) doc.PageLeft = 0;
}
}
}
int y, int z, int xsize, int ysize, int yerr0,
int yerr1, cups_ib_t *r0, cups_ib_t *r1);
static void make_lut(cups_ib_t *, int, float, float);
-static int raster_cb(cups_page_header2_t *header, int preferred_bits);
/*
xc1, yc1;
ppd_file_t *ppd; /* PPD file */
ppd_choice_t *choice; /* PPD option choice */
+ cups_cspace_t cspace = -1; /* CUPS color space */
char *resolution, /* Output resolution */
*media_type; /* Media type */
ppd_profile_t *profile; /* Color profile */
customRight = 0.0, /* ppd->custom_margin[2] */
customTop = 0.0; /* ppd->custom_margin[3] */
char defSize[41];
+ filter_out_format_t outformat;
+
+ /* Note: With the OUTPUT_FORMAT_APPLE_RASTER,
+ OUTPUT_FORMAT_PWG_RASTER, or OUTPUT_FORMAT_PCLM selections the
+ output is actually CUPS Raster but information about available
+ color spaces and depths are taken from the urf-supported or
+ pwg-raster-document-type-supported printer IPP attributes or
+ appropriate PPD file attributes (PCLM is always sRGB
+ 8-bit). These modes are for further processing with rastertopwg
+ or rastertopclm. This can change in the future when we add Apple
+ Raster and PWG Raster output support to this filter. */
+
+ if (parameters) {
+ outformat = *(filter_out_format_t *)parameters;
+ if (outformat != OUTPUT_FORMAT_PCLM &&
+ outformat != OUTPUT_FORMAT_CUPS_RASTER &&
+ outformat != OUTPUT_FORMAT_PWG_RASTER &&
+ outformat != OUTPUT_FORMAT_APPLE_RASTER)
+ outformat = OUTPUT_FORMAT_CUPS_RASTER;
+ } else
+ outformat = OUTPUT_FORMAT_CUPS_RASTER;
+
+ if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetorater: Final output format: %s",
+ (outformat == OUTPUT_FORMAT_CUPS_RASTER ? "CUPS Raster" :
+ (outformat == OUTPUT_FORMAT_PWG_RASTER ? "PWG Raster" :
+ (outformat == OUTPUT_FORMAT_APPLE_RASTER ? "Apple Raster" :
+ "PCLm"))));
if (printer_attrs != NULL) {
int left, right, top, bottom;
* Process job options...
*/
+ cupsRasterPrepareHeader(&header, data, outformat,
+ OUTPUT_FORMAT_CUPS_RASTER, &cspace);
ppd = data->ppd;
- if (ppd)
+ doc.Orientation = header.Orientation;
+ doc.Duplex = header.Duplex;
+ doc.LanguageLevel = 1;
+ doc.Color = header.cupsNumColors>1?1:0;
+ doc.PageLeft = header.cupsImagingBBox[0] != 0.0 ?
+ header.cupsImagingBBox[0] :
+ (float)header.ImagingBoundingBox[0];
+ doc.PageRight = header.cupsImagingBBox[2] != 0.0 ?
+ header.cupsImagingBBox[2] :
+ (float)header.ImagingBoundingBox[2];
+ doc.PageTop = header.cupsImagingBBox[3] != 0.0 ?
+ header.cupsImagingBBox[3] :
+ (float)header.ImagingBoundingBox[3];
+ doc.PageBottom = header.cupsImagingBBox[1] != 0.0 ?
+ header.cupsImagingBBox[1] :
+ (float)header.ImagingBoundingBox[1];
+ doc.PageWidth = header.cupsPageSize[0] != 0.0 ?
+ header.cupsPageSize[0] :
+ (float)header.PageSize[0];
+ doc.PageLength = header.cupsPageSize[1] != 0.0 ?
+ header.cupsPageSize[1] :
+ (float)header.PageSize[1];
+
+ if (log)
{
- filterSetCommonOptions(ppd, num_options, options, 0,
- &doc.Orientation, &doc.Duplex,
- &doc.LanguageLevel, &doc.Color,
- &doc.PageLeft, &doc.PageRight,
- &doc.PageTop, &doc.PageBottom,
- &doc.PageWidth, &doc.PageLength,
- log, ld);
- }
- else
- {
- cupsRasterParseIPPOptions(&header, data, 0, 1);
- doc.Orientation = header.Orientation;
- doc.Duplex = header.Duplex;
- doc.LanguageLevel = 1;
- doc.Color = header.cupsNumColors>1?1:0;
- doc.PageLeft = header.cupsImagingBBox[0] != 0.0 ?
- header.cupsImagingBBox[0] :
- (float)header.ImagingBoundingBox[0];
- doc.PageRight = header.cupsImagingBBox[2] != 0.0 ?
- header.cupsImagingBBox[2] :
- (float)header.ImagingBoundingBox[2];
- doc.PageTop = header.cupsImagingBBox[3] != 0.0 ?
- header.cupsImagingBBox[3] :
- (float)header.ImagingBoundingBox[3];
- doc.PageBottom = header.cupsImagingBBox[1] != 0.0 ?
- header.cupsImagingBBox[1] :
- (float)header.ImagingBoundingBox[1];
- doc.PageWidth = header.cupsPageSize[0] != 0.0 ?
- header.cupsPageSize[0] :
- (float)header.PageSize[0];
- doc.PageLength = header.cupsPageSize[1] != 0.0 ?
- header.cupsPageSize[1] :
- (float)header.PageSize[1];
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.color = %d", doc.Color);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.Orientation = %d", doc.Orientation);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.Duplex = %d", doc.Duplex);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageWidth = %.1f", doc.PageWidth);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageLength = %.1f", doc.PageLength);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageLeft = %.1f", doc.PageLeft);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageRight = %.1f", doc.PageRight);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageTop = %.1f", doc.PageTop);
+ log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: doc.PageBottom = %.1f", doc.PageBottom);
}
-if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "doc.color = %d", doc.Color);
-/* Find print-rendering-intent */
- getPrintRenderIntent(data, &header);
- if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
- "Print rendering intent = %s", header.cupsRenderingIntent);
+ /* Find print-rendering-intent */
+
+ getPrintRenderIntent(data, &header);
+ if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
+ "imagetoraster: Print rendering intent = %s",
+ header.cupsRenderingIntent);
if ((val = cupsGetOption("multiple-document-handling",
num_options, options)) != NULL)
!strcasecmp(val, "yes")))
doc.Flip = 1;
- /*
- * Set the needed options in the page header...
- */
- if(ppd!=NULL)
- if (ppdRasterInterpretPPD(&header, ppd, num_options, options, raster_cb))
- {
- if (log) {
- log(ld, FILTER_LOGLEVEL_ERROR,
- "imagetoraster: The page setup information was not valid.");
- log(ld, FILTER_LOGLEVEL_DEBUG,
- "imagetoraster: %s", cupsRasterErrorString());
- }
- if (!inputseekable)
- unlink(tempfile);
- return (1);
- }
-
/*
* Get the media type and resolution that have been chosen...
*/
}
else {
float final_w=w,final_h=h;
- if(w>pw)
- {
- final_w = pw;
- }
- if(h>ph)
- {
- final_h = ph;
- }
- if((fabs(final_w-w)>0.5*w)||(fabs(final_h-h)>0.5*h))
+ if (w > pw * img->xppi / 72.0)
+ final_w = pw * img->xppi / 72.0;
+ if (h > ph * img->yppi / 72.0)
+ final_h = ph * img->yppi / 72.0;
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+doc.XPosition)*posw;
+ posh = (1-doc.YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
+ cupsImageClose(img);
+ img = img2;
+ if(flag==4)
{
- if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
- "imagetoraster: Ignoring crop-to-fit option!");
- cropfit=0;
- }
- else{
- float posw=(w-final_w)/2,posh=(h-final_h)/2;
- posw = (1+doc.XPosition)*posw;
- posh = (1-doc.YPosition)*posh;
- cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
- cupsImageClose(img);
- img = img2;
- if(flag==4)
- {
- doc.PageBottom+=(doc.PageTop-doc.PageBottom-final_w)/2;
- doc.PageTop = doc.PageBottom+final_w;
- doc.PageLeft +=(doc.PageRight-doc.PageLeft-final_h)/2;
- doc.PageRight = doc.PageLeft+final_h;
- }
- else{
- doc.PageBottom+=(doc.PageTop-doc.PageBottom-final_h)/2;
- doc.PageTop = doc.PageBottom+final_h;
- doc.PageLeft +=(doc.PageRight-doc.PageLeft-final_w)/2;
- doc.PageRight = doc.PageLeft+final_w;
- }
- if(doc.PageBottom<0) doc.PageBottom = 0;
- if(doc.PageLeft<0) doc.PageLeft = 0;
- }
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_w * 72.0 / img->xppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_w * 72.0 / img->xppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_h * 72.0 / img->yppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_h * 72.0 / img->yppi;
+ }
+ else
+ {
+ doc.PageBottom += (doc.PageTop - doc.PageBottom -
+ final_h * 72.0 / img->yppi) / 2;
+ doc.PageTop = doc.PageBottom +
+ final_h * 72.0 / img->yppi;
+ doc.PageLeft += (doc.PageRight - doc.PageLeft -
+ final_w * 72.0 / img->xppi) / 2;
+ doc.PageRight = doc.PageLeft +
+ final_w * 72.0 / img->xppi;
+ }
+ if(doc.PageBottom<0) doc.PageBottom = 0;
+ if(doc.PageLeft<0) doc.PageLeft = 0;
}
}
}
*lut++ = v;
}
}
-
-
-/*
- * 'raster_cb()' - Validate the page header.
- */
-
-static int /* O - 0 if OK, -1 if not */
-raster_cb(
- cups_page_header2_t *header, /* IO - Raster header */
- int preferred_bits) /* I - Preferred bits per color */
-{
- /*
- * Ensure that colorimetric colorspaces use at least 8 bits per
- * component...
- */
-
- if ((header->cupsColorSpace == CUPS_CSPACE_CIEXYZ ||
- header->cupsColorSpace == CUPS_CSPACE_CIELab ||
- header->cupsColorSpace >= CUPS_CSPACE_ICC1) &&
- header->cupsBitsPerColor < 8)
- header->cupsBitsPerColor = 8;
-
- return (0);
-}
filter_iscanceledfunc_t iscanceled = data->iscanceledfunc;
void *icd = data->iscanceleddata;
char **envp;
+ cups_cspace_t cspace = -1;
#ifdef HAVE_CUPS_1_7
ppd_attr_t *attr;
goto out;
}
- if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftoraster: command: %s\n",CUPS_MUTOOL);
+ if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftoraster: command: %s",
+ CUPS_MUTOOL);
snprintf(tmpstr, sizeof(tmpstr), "%s", CUPS_MUTOOL);
cupsArrayAdd(mupdf_args, strdup(tmpstr));
cupsArrayAdd(mupdf_args, strdup("draw"));
cupsArrayAdd(mupdf_args, strdup("-Fpwg"));
/* Note that MuPDF only creates PWG Raster and never CUPS Raster,
- so we always set the PWG Raster flag in the cupsRasterParseIPPOptions()
- calls.
- Make also sure that the width and height of the page in pixels is
- the size of the full page (as PWG Raster and MuPDF require it) and not
- only the printable area (as ppdRasterInterpretPPD() sets, to fulfill
- CUPS Raster standard)
+ so we set the PWG Raster flag in the cupsRasterPrepareHeader() call.
+ This function takes care of generating a completely consistent PWG
+ Raster header then, no extra manipulation needed.
From the header h only cupsWidth/cupsHeight (dimensions in pixels),
resolution, and color space are used here. */
- if (ppd) {
- ppdRasterInterpretPPD(&h, ppd, num_options, options, 0);
- h.cupsWidth = h.HWResolution[0] * h.PageSize[0] / 72;
- h.cupsHeight = h.HWResolution[1] * h.PageSize[1] / 72;
- } else {
-#ifdef HAVE_CUPS_1_7
- cupsRasterParseIPPOptions(&h, &curr_data, 1, 1);
-#else
- if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: No PPD file specified.");
- goto out;
-#endif /* HAVE_CUPS_1_7 */
- }
+ cupsRasterPrepareHeader(&h, &curr_data, OUTPUT_FORMAT_PWG_RASTER,
+ OUTPUT_FORMAT_PWG_RASTER, &cspace);
if ((h.HWResolution[0] == 100) && (h.HWResolution[1] == 100)) {
/* No "Resolution" option */
filter_logfunc_t log = data->logfunc;
void *ld = data ->logdata;
ipp_t *printer_attrs = data->printer_attrs;
+ cups_cspace_t cspace = (cups_cspace_t)(-1);
+
+ /* Note: With the OUTPUT_FORMAT_APPLE_RASTER or OUTPUT_FORMAT_PCLM
+ selections the output is actually CUPS Raster but information
+ about available color spaces and depths is taken from the
+ urf-supported printer IPP attribute or the appropriate PPD file
+ attribute (PCLM is always sRGB 8-bit). These modes are for
+ further processing with rastertopwg or rastertopclm. This can
+ change in the future when we add Apple Raster output support to
+ this filter. */
+
#ifdef HAVE_CUPS_1_7
if (parameters) {
outformat = *(filter_out_format_t *)parameters;
if (outformat != OUTPUT_FORMAT_CUPS_RASTER &&
- outformat != OUTPUT_FORMAT_PWG_RASTER)
+ outformat != OUTPUT_FORMAT_PWG_RASTER &&
+ outformat != OUTPUT_FORMAT_APPLE_RASTER &&
+ outformat != OUTPUT_FORMAT_PCLM)
outformat = OUTPUT_FORMAT_CUPS_RASTER;
} else
outformat = OUTPUT_FORMAT_CUPS_RASTER;
doc->pwgraster = 1;
#endif /* HAVE_CUPS_1_7 */
+ num_options = joinJobOptionsAndAttrs(data, num_options, &options);
+
if (data->ppd)
doc->ppd = data->ppd;
else if (data->ppdfile)
doc->ppd = ppdOpenFile(data->ppdfile);
- if (doc->ppd == NULL)
+ if (doc->ppd) {
+ ppdMarkOptions(doc->ppd,num_options,options);
+ handleRqeuiresPageRegion(doc);
+ } else
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"pdftoraster: PPD file is not specified.");
- num_options = joinJobOptionsAndAttrs(data, num_options, &options);
+ cupsRasterPrepareHeader(&(doc->header), data, outformat,
+ (outformat == OUTPUT_FORMAT_PWG_RASTER ?
+ outformat : OUTPUT_FORMAT_CUPS_RASTER),
+ &cspace);
+
if (doc->ppd) {
- ppdMarkOptions(doc->ppd,num_options,options);
- handleRqeuiresPageRegion(doc);
- ppdRasterInterpretPPD(&(doc->header),doc->ppd,num_options,options,0);
attr = ppdFindAttr(doc->ppd,"pdftorasterRenderingIntent",NULL);
if (attr != NULL && attr->value != NULL) {
if (strcasecmp(attr->value,"PERCEPTUAL") == 0) {
else
doc->pwgraster = 0;
}
- cupsRasterParseIPPOptions(&(doc->header),data,doc->pwgraster,1);
getPrintRenderIntent(data, &(doc->header));
if(strcasecmp(doc->header.cupsRenderingIntent, "PERCEPTUAL")==0){
doc->colour_profile.renderingIntent = INTENT_PERCEPTUAL;
/* select convertLine function */
static int selectConvertFunc(cups_raster_t *raster, pdftoraster_doc_t* doc, conversion_function_t *convert, filter_logfunc_t log, void* ld)
{
+ doc->bitspercolor = doc->header.cupsBitsPerColor;
if ((doc->colour_profile.colorProfile == NULL || doc->colour_profile.popplerColorProfile == doc->colour_profile.colorProfile)
&& (doc->header.cupsColorOrder == CUPS_ORDER_CHUNKED
|| doc->header.cupsNumColors == 1)) {
(doc->header.cupsNumColors == 1 ||
doc->header.cupsColorSpace == CUPS_CSPACE_KCMYcm ))
doc->bitspercolor = 0; /*Do not convertbits*/
- else
- doc->bitspercolor = doc->header.cupsBitsPerColor;
return (0);
}
filter_logfunc_t log,
void* ld)
{
+ doc->bitspercolor = doc->outheader.cupsBitsPerColor;
+
if ((doc->color_profile.colorProfile == NULL || doc->color_profile.outputColorProfile == doc->color_profile.colorProfile)
&& (doc->outheader.cupsColorOrder == CUPS_ORDER_CHUNKED
|| doc->outheader.cupsNumColors == 1)) {
(doc->outheader.cupsNumColors == 1 ||
doc->outheader.cupsColorSpace == CUPS_CSPACE_KCMYcm ))
doc->bitspercolor = 0; /*Do not convertbits*/
- else
- doc->bitspercolor = doc->outheader.cupsBitsPerColor;
return (0);
}
-1 on error */
cupsRasterPrepareHeader(cups_page_header2_t *h, /* I - Raster header */
filter_data_t *data, /* I - Job and printer data */
- filter_out_format_t final_content_type,
- /* I - Job output format */
+ filter_out_format_t final_outformat,
+ /* I - Job output format
+ (determines color space,
+ and resolution) */
+ filter_out_format_t header_outformat,
+ /* I - This filter's output
+ format (determines
+ header format) */
cups_cspace_t *cspace) /* IO - Color space we want to
use, -1 for auto, we
return color space
appleraster = 0,
cupsraster = 0,
pclm = 0;
+ int cupsrasterheader = 1;
const char *p;
ppd_attr_t *ppd_attr;
ipp_attribute_t *attr;
double margins[4];
double dimensions[2];
+ if (final_outformat == OUTPUT_FORMAT_PWG_RASTER)
+ pwgraster = 1;
+ else if (final_outformat == OUTPUT_FORMAT_APPLE_RASTER)
+ appleraster = 1;
+ else if (final_outformat == OUTPUT_FORMAT_PCLM)
+ pclm = 1;
+ else
+ cupsraster = 1;
+
+ if (header_outformat == OUTPUT_FORMAT_PWG_RASTER ||
+ header_outformat == OUTPUT_FORMAT_APPLE_RASTER)
+ cupsrasterheader = 0;
+
printer_attrs = data->printer_attrs;
job_attrs = data->job_attrs;
printer_attrs = data->printer_attrs;
job_attrs = data->job_attrs;
- if (final_content_type == OUTPUT_FORMAT_PWG_RASTER)
- pwgraster = 1;
- else if (final_content_type == OUTPUT_FORMAT_APPLE_RASTER)
- appleraster = 1;
- else if (final_content_type == OUTPUT_FORMAT_PCLM)
- pclm = 1;
- else
- cupsraster = 1;
-
/* These values will be used in case we don't find supported resolutions
- for given OUTFORMAT */
+ for given output format */
if ((attr = ippFindAttribute(printer_attrs, "printer-resolution-default",
IPP_TAG_RESOLUTION)) != NULL)
{
else
yres = xres;
}
- /* Finding supported resolution for given outFormat */
+ /* Finding supported resolution for given output format */
if (pwgraster)
{
if ((attr = ippFindAttribute(printer_attrs,
for (i = 0; i < 2; i ++)
dimensions[i] = h->PageSize[i];
- if (cupsraster) {
+ if (cupsrasterheader) {
margins[0] = h->cupsImagingBBox[0];
margins[1] = h->cupsImagingBBox[1];
margins[2] = dimensions[0] - h->cupsImagingBBox[2];
pwgraster = 0;
}
}
- cupsRasterParseIPPOptions(h, data, pwgraster, 1);
+ cupsRasterParseIPPOptions(h, data, 1 - cupsrasterheader, 1);
if (ippRasterMatchIPPSize(h, data, margins, dimensions, NULL, NULL) < 0) {
for (i = 0; i < 2; i ++)
dimensions[i] = h->PageSize[i];
memset(margins, 0, sizeof(margins));
}
- if (!cupsraster)
+ if (!cupsrasterheader)
memset(margins, 0, sizeof(margins));
if (printer_attrs &&
}
/* Make all page geometry fields in the header consistent */
- if (cupsraster) {
+ if (cupsrasterheader) {
h->cupsWidth = ((dimensions[0] - margins[0] - margins[2]) /
72.0 * h->HWResolution[0]) + 0.5;
h->cupsHeight = ((dimensions[1] - margins[1] - margins[3]) /
for (i = 0; i < 2; i ++) {
h->cupsPageSize[i] = dimensions[i];
h->PageSize[i] = (unsigned int)(h->cupsPageSize[i] + 0.5);
- if (cupsraster)
+ if (cupsrasterheader)
h->Margins[i] = margins[i] + 0.5;
else
h->Margins[i] = 0;
}
- if (cupsraster) {
+ if (cupsrasterheader) {
h->cupsImagingBBox[0] = margins[0];
h->cupsImagingBBox[1] = margins[1];
h->cupsImagingBBox[2] = dimensions[0] - margins[2];
if (h->cupsColorOrder == CUPS_ORDER_BANDED)
h->cupsBytesPerLine *= h->cupsNumColors;
+ /* Mark header as PWG Raster if it is not CUPS Raster */
+ if (!cupsrasterheader)
+ strcpy(h->MediaClass, "PwgRaster");
+
cupsFreeOptions(num_options, options);
return (0);
extern int cupsRasterPrepareHeader(cups_page_header2_t *h,
filter_data_t *data,
filter_out_format_t
- final_content_type,
+ final_outformat,
+ filter_out_format_t
+ header_outformat,
cups_cspace_t *cspace);
extern int cupsRasterSetColorSpace(cups_page_header2_t *h,
const char *available,
* Fire up the imagetoraster() filter function
*/
- ret = filterCUPSWrapper(argc, argv, imagetoraster, NULL, &JobCanceled);
+ filter_out_format_t outformat = OUTPUT_FORMAT_CUPS_RASTER;
+ char *t = getenv("FINAL_CONTENT_TYPE");
+ if (t) {
+ if (strcasestr(t, "pwg"))
+ outformat = OUTPUT_FORMAT_PWG_RASTER;
+ else if (strcasestr(t, "urf"))
+ outformat = OUTPUT_FORMAT_APPLE_RASTER;
+ else if (strcasestr(t, "pclm"))
+ outformat = OUTPUT_FORMAT_PCLM;
+ }
+
+ ret = filterCUPSWrapper(argc, argv, imagetoraster, &outformat, &JobCanceled);
if (ret)
fprintf(stderr, "ERROR: imagetoraster filter function failed.\n");
outformat = OUTPUT_FORMAT_PWG_RASTER;
else if (strcasestr(t, "cups"))
outformat = OUTPUT_FORMAT_CUPS_RASTER;
+ else if (strcasestr(t, "urf"))
+ outformat = OUTPUT_FORMAT_APPLE_RASTER;
+ else if (strcasestr(t, "pclm"))
+ outformat = OUTPUT_FORMAT_PCLM;
}
ret = filterCUPSWrapper(argc, argv, pdftoraster, &outformat, &JobCanceled);