diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2021-08-31 11:19:38 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2021-08-31 11:20:07 +0100 |
commit | 74f11156cad81f91922dbb9488215a8610cd6d9a (patch) | |
tree | 5c9c1858e944f8881c7c2bf38b90c99a3f10cbc1 | |
parent | 7677c955cc5ba202fb93d5d2e3948dc3ce196759 (diff) | |
download | ghostpdl-74f11156cad81f91922dbb9488215a8610cd6d9a.tar.gz |
GhostPDF - warn on use of /DeviceN /All
The /All in name is illegal in PDF (it is valid in PostScript). Acrobat
allegedly seems to accept this; if the ink name array only has one
entry and the entry is /All it seems to convert it to a /Sepaaration
/All, which is equivalent.
However sometimes (tests_private/comparefiles/Testform.v1.0.2.pdf) it
throws an error instead. Possibly this is a change in behaviour with
more recent versions of Acrobat.
In any event, we now raise a warning.
-rw-r--r-- | pdf/ghostpdf.c | 5 | ||||
-rw-r--r-- | pdf/ghostpdf.h | 1 | ||||
-rw-r--r-- | pdf/pdf_colour.c | 17 |
3 files changed, 20 insertions, 3 deletions
diff --git a/pdf/ghostpdf.c b/pdf/ghostpdf.c index bfa8b7756..e0eaa1d9a 100644 --- a/pdf/ghostpdf.c +++ b/pdf/ghostpdf.c @@ -374,8 +374,9 @@ const char *pdf_warning_strings[] = { "bad trailer dictionary", "error in annotation", "failed to create ICC profile link", - "overflowed a real reading a number, assuming 0" - "failed to read a valid number, assuming 0" + "overflowed a real reading a number, assuming 0", + "failed to read a valid number, assuming 0", + "A DeviceN space used the /All ink name." "" /* Last warning shuld not be used */ }; diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h index b83e3ea02..9d10d0f74 100644 --- a/pdf/ghostpdf.h +++ b/pdf/ghostpdf.h @@ -115,6 +115,7 @@ typedef enum pdf_warning_e { W_PDF_BAD_ICC_PROFILE_LINK, W_PDF_OVERFLOW_REAL, W_PDF_INVALID_REAL, + W_PDF_DEVICEN_USES_ALL, W_PDF_MAX_WARNING /* Must be last entry, add new warnings immediately before this and update pdf_warning_strings in ghostpdf.c */ } pdf_warning; diff --git a/pdf/pdf_colour.c b/pdf/pdf_colour.c index aa5048eb7..e6061db1f 100644 --- a/pdf/pdf_colour.c +++ b/pdf/pdf_colour.c @@ -1665,8 +1665,23 @@ static int pdfi_create_DeviceN(pdf_context *ctx, pdf_array *color_array, int ind if (code < 0) goto pdfi_devicen_error; + for (ix = 0;ix < pdfi_array_size(inks);ix++) { + pdf_name *ink_name = NULL; + + code = pdfi_array_get_type(ctx, inks, ix, PDF_NAME, (pdf_obj **)&ink_name); + if (code < 0) + return code; + + if (ink_name->length == 3 && memcmp(ink_name->data, "All", 3) == 0) { + pdfi_set_warning(ctx, 0, NULL, W_PDF_DEVICEN_USES_ALL, "pdfi_create_DeviceN", (char *)"WARNING: DeviceN space using /All ink name"); + } + pdfi_countdown(ink_name); + ink_name = NULL; + } + /* Sigh, Acrobat allows this, even though its contra the spec. Convert to - * a /Separation space, and then return. + * a /Separation space, and then return. Actually Acrobat does not always permit this, see + * tests_private/comparefiles/Testform.v1.0.2.pdf. */ if (pdfi_array_size(inks) == 1) { pdf_name *ink_name = NULL; |