diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2023-03-18 10:45:00 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2023-03-18 10:46:10 +0000 |
commit | 3abb368c6262e657402ea5ae01e6d91217427e0e (patch) | |
tree | e38b0c36312b07b19a2b36b4aed852171a63eeed /devices | |
parent | 5c2e7698fa7e3ef97e41290548ec860a4c0ab46d (diff) | |
download | ghostpdl-3abb368c6262e657402ea5ae01e6d91217427e0e.tar.gz |
ps2write - prevent PSPageOptions wrapping
As requested by customer 1120. The PSPageOptions array is used to
specify strings to be inserted into the PostScript output of the
ps2write device; the intention is to permit device-specific code to be
placed on each page.
Ordinarily the array contains one string for each page of the output,
and that string is applied individiually.
To assist in the common cases where a pattern of different setup is
applied to pages, such as treating each of a pair of pages differently,
for every pair of pages, the processing 'wraps around' the array if
there are more pages than strings. So if we supply two strings the first
string will be applied to pages 1, 3, 5, ... and the second string will
be applied to page 2, 4, 6, ....
The customer wants to disable the 'wrap around' so that if they supply
fewer strings than pages, the device simply stops adding strings when
it runs out of content in the array.
There is no practical way to do this by altering the array content
because it is actually quite awkward to deal with heterogeneous
parameter arrays. Rather than rewrite the code extensively I've chosen
(reluctantly) to add a new parameter 'PSPageOptionsWrap'. When true
(the default value) then the behaviour is unchanged. When false the
ps2write device no longer wraps around the array, but simply stops
adding content to each page.
Diffstat (limited to 'devices')
-rw-r--r-- | devices/vector/gdevpdf.c | 14 | ||||
-rw-r--r-- | devices/vector/gdevpsdf.h | 1 | ||||
-rw-r--r-- | devices/vector/gdevpsdp.c | 1 |
3 files changed, 10 insertions, 6 deletions
diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c index 0adefbf68..d41c5eba7 100644 --- a/devices/vector/gdevpdf.c +++ b/devices/vector/gdevpdf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2022 Artifex Software, Inc. +/* Copyright (C) 2001-2023 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -3078,12 +3078,14 @@ pdf_close(gx_device * dev) stream_puts(pdev->strm, "%%BeginPageSetup\n"); if (pdev->params.PSPageOptions.size) { - int i, index = (pagecount - 1) % pdev->params.PSPageOptions.size; - char *p = (char *)pdev->params.PSPageOptions.data[index].data; + if (pdev->params.PSPageOptionsWrap || (pagecount - 1) < pdev->params.PSPageOptions.size) { + int i, index = (pagecount - 1) % pdev->params.PSPageOptions.size; + char *p = (char *)pdev->params.PSPageOptions.data[index].data; - for (i=0;i<pdev->params.PSPageOptions.data[index].size;i++) - stream_putc(s, *p++); - stream_puts(pdev->strm, "\n"); + for (i=0;i<pdev->params.PSPageOptions.data[index].size;i++) + stream_putc(s, *p++); + stream_puts(pdev->strm, "\n"); + } } pdf_write_page(pdev, pagecount++); diff --git a/devices/vector/gdevpsdf.h b/devices/vector/gdevpsdf.h index 00a7b4ee7..485fb0490 100644 --- a/devices/vector/gdevpsdf.h +++ b/devices/vector/gdevpsdf.h @@ -182,6 +182,7 @@ typedef struct psdf_distiller_params_s { bool PassThroughJPXImages; gs_param_string PSDocOptions; gs_param_string_array PSPageOptions; + bool PSPageOptionsWrap; } psdf_distiller_params; /* Declare templates for default image compression filters. */ diff --git a/devices/vector/gdevpsdp.c b/devices/vector/gdevpsdp.c index bd0016973..39cab4670 100644 --- a/devices/vector/gdevpsdp.c +++ b/devices/vector/gdevpsdp.c @@ -244,6 +244,7 @@ static const gs_param_item_t psdf_param_items[] = { pi("SubsetFonts", gs_param_type_bool, SubsetFonts), pi("PassThroughJPEGImages", gs_param_type_bool, PassThroughJPEGImages), pi("PassThroughJPXImages", gs_param_type_bool, PassThroughJPXImages), + pi("PSPageOptionsWrap", gs_param_type_bool, PSPageOptionsWrap), #undef pi gs_param_item_end |