diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2021-10-22 14:31:28 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2021-10-22 14:31:28 +0100 |
commit | 7902518d3e219c719c74297ea5520080a55e73f8 (patch) | |
tree | 601ba4daf512ff684ba9ce889bfaa8fe9f6918fe | |
parent | 87f6f916252b079aa71360e1a45d2e146d5852e1 (diff) | |
download | ghostpdl-7902518d3e219c719c74297ea5520080a55e73f8.tar.gz |
GhostPDF - reset spot capable devices to undo PL setting
The PL layer specifically disables spot colour handling, possibly for
the benefit of the XPS interpreter, the comment in
pl_main_process_options() isn't totally clear.
The only way for us to put that back, and get more than 4 spot plates
out of a spot capable device, is to close the device, reset the value
to -1, and reopen it.
This leads to us closing and opening the device a lot more than we need
to, which is very wasteful, for the future; try and optimise this and
pdf_check so that we don't need to reopen the device so much.
-rw-r--r-- | pdf/pdf_device.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pdf/pdf_device.c b/pdf/pdf_device.c index 6d7547e2f..4b40ae19e 100644 --- a/pdf/pdf_device.c +++ b/pdf/pdf_device.c @@ -136,6 +136,34 @@ void pdfi_device_set_flags(pdf_context *ctx) /* See if it is a DeviceN (spot capable) */ ctx->device_state.spot_capable = dev_proc(dev, dev_spec_op)(dev, gxdso_supports_devn, NULL, 0); + /* This code is fankly icky and deserves to be changed. The problem it solves is that the + * PL interpreter code layer specifically sets "PageSpotColours" to 0 (none) in plmain.c + * pl_main_process_options(). Once that has been done, there is no simple way to + * process more than 4 spot channels. I thought at first we could use pl_main_post_args_init() + * but that doesn't get access to the main instance (where the params are stored) or to the + * params directly so it is unable to change them. + * So the only solution is either to remove the code which sets the PageSpotColours to 0, or + * to close the device, set the PageSpotColours to -1 (unknown) and re-open the device. + * That's what we do here. This means we end up closing and re-opening the device a lot, + * I'd like to avoid that so : + * FIXME: only do this once, ideally only call pdfi_device_set_flags once + */ + if (ctx->device_state.spot_capable && dev->is_open) { + gs_c_param_list params; + int num_spots = -1; + + gs_closedevice(dev); + + gs_c_param_list_write(¶ms, ctx->memory); + (void)param_write_int((gs_param_list *)¶ms, "PageSpotColors", &(num_spots)); + gs_c_param_list_read(¶ms); + (void)gs_putdeviceparams(ctx->pgs->device, (gs_param_list *)¶ms); + gs_c_param_list_release(¶ms); + + (void)gs_setdevice_no_erase(ctx->pgs, ctx->pgs->device); + gs_erasepage(ctx->pgs); + } + /* If multi-page output, can't do certain pdfmarks */ if (ctx->device_state.writepdfmarks) { if (gx_outputfile_is_separate_pages(((gx_device_vector *)dev)->fname, dev->memory)) { |