summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2023-02-09 16:25:54 +0000
committerKen Sharp <ken.sharp@artifex.com>2023-02-09 16:27:03 +0000
commit95db9c543abdeb391d852aad7f0c5c419f808069 (patch)
tree86bbba1a43d0c35a9cc414fb220711dea73f9c51 /devices
parent0b1950025dc8bead227a764717c016dbdf27f2ce (diff)
downloadghostpdl-95db9c543abdeb391d852aad7f0c5c419f808069.tar.gz
pdfwrite - preserve both true and false stroke adjustment
Bug #706407 "pdfwrite does not write /SA false unless it has previously been set to true" The pdfwrite device only writes graphics state parameters which have changed. The default value for the stroke adjust was set to false, so if an input file set it to false, then pdfwrite would not write the value to the output file. The value is set to false because that is what the PDF Reference states the default to be. However, it appears that Acrobat defaults to true. This leads to different rendering for files which have /SA false and files which do not set /SA. Interestingly at low resolution Ghostscript also defaults to true. The only way to deal with this is to have the initial value in the viewer graphics state be neither true nor false. Then if an input file never sets SA we will not write it, but if it does set it, no matter what it gets set to, we will write it to the output. This change results in a number of differences when cluster tested at low resolution, and leads to a number of output files being reported as increasing in size, naturally since we now write SA values when we would not have before. Checking the diffs we see that the files now match the rendering of the original input file, whereas the file output by pdfwrite did not match the original file, because the /SA false had been dropped.
Diffstat (limited to 'devices')
-rw-r--r--devices/vector/gdevpdfg.c11
-rw-r--r--devices/vector/gdevpdfx.h4
2 files changed, 11 insertions, 4 deletions
diff --git a/devices/vector/gdevpdfg.c b/devices/vector/gdevpdfg.c
index 3e2a2b6d5..73f78dd18 100644
--- a/devices/vector/gdevpdfg.c
+++ b/devices/vector/gdevpdfg.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
@@ -224,7 +224,14 @@ pdf_viewer_state_from_gs_gstate_aux(pdf_viewer_state *pvs, const gs_gstate *pgs)
pvs->text_knockout = pgs->text_knockout;
pvs->fill_overprint = false;
pvs->stroke_overprint = false;
- pvs->stroke_adjust = false;
+ /* The PDF Reference says that the default is 'false' but experiments show (bug #706407)
+ * that Acrobat defaults to true. Also Ghostscript, at low resolution at least, defaults
+ * to true as well. By setting the initial value to neither true nor false we can ensure
+ * that any input file which sets it, whether true or false, will cause it not to match
+ * the initial value, so we will write it out, thus preserving the value, no matter what
+ * the default.
+ */
+ pvs->stroke_adjust = -1;
pvs->line_params.half_width = 0.5;
pvs->line_params.start_cap = 0;
pvs->line_params.end_cap = 0;
diff --git a/devices/vector/gdevpdfx.h b/devices/vector/gdevpdfx.h
index b41c9648b..e2b7c98d5 100644
--- a/devices/vector/gdevpdfx.h
+++ b/devices/vector/gdevpdfx.h
@@ -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
@@ -503,7 +503,7 @@ typedef struct pdf_viewer_state_s {
bool text_knockout; /* state.text_knockout */
bool fill_overprint;
bool stroke_overprint;
- bool stroke_adjust; /* state.stroke_adjust */
+ int stroke_adjust; /* state.stroke_adjust */
bool fill_used_process_color;
bool stroke_used_process_color;
gx_hl_saved_color saved_fill_color;