pdf-association / pdf-issues

Industry-based resolutions for issues and errata reported against any PDF-related specification
https://pdf-issues.pdfa.org/
66 stars 2 forks source link

How to define shading patterns? #381

Open seehuhn opened 8 months ago

seehuhn commented 8 months ago

For almost all colour types, the corresponding section in the spec describes how to define the corresponding colour space, and how to select colours from this colour space. The only exception seem to be shading patterns. In this section, I did not find the required information. If the information is indeed missing, it should be added near the start of section 8.7.4 (Shading patterns).

Examples of where the information is present:

The only text along these lines I found in section 8.7.4 (Shading patterns) is: "Patterns of this type shall be described by pattern dictionaries with a pattern type of 2", but this seems much less explicit than the descriptions given in the other sections. Maybe text similar to the examples above could be added to section 8.7.4.1?

My guess is that shading pattern are selected using operators like the following:

/Pattern CS
/P1 SCN

where P1 is the entry for the pattern dictionary in the Pattern sub-dictionary in the Resources dictionary.

DietrichSeggern commented 8 months ago

In "8.7.2 General properties of patterns" there is: "All patterns shall be treated as colours; a Pattern colour space shall be established with the CS or cs operator just like other colour spaces, and a particular pattern shall be installed as the current colour with the SCN or scn operator (see "Table 73 — Colour operators")."

Does this resolve the issue or do you think there should be something in addition to this?

seehuhn commented 8 months ago

@DietrichSeggern The thing which I believe is not specified is, what the arguments of the CS and SCN operators should be in this case. My guess is, that the argument to CS should be \Pattern, and the the argument of SCN should be a single name pointing into the pattern dictionary in Resources, and in the pattern dictionary probably you should have a PDF dict which looks a bit like the stream dict of a coloured tiling pattern. But that's just a guess, I could not find a place where the spec actually says this.

petervwyatt commented 8 months ago

Does Table 73 - Colour operators cover what you're after for scn/SCN (and thus also sc/SC)?

If the current stroking colour space is a Pattern colour space, name shall be the name of an entry in the Pattern subdictionary of the current resource dictionary (see 7.8.3, "Resource dictionaries"). For an uncoloured tiling pattern (PatternType = 1 and PaintType = 2), c1… cn shall be component values specifying a colour in the pattern’s underlying colour space. For other types of patterns, these operands shall not be specified.

seehuhn commented 8 months ago

I think the text you quote specifies the arguments for scn and SCN. Maybe this also makes the text in Section 8.7.3.2 for coloured tiling patters (quoted in my original report) redundant.

I still can't see where it says what the argument to cs and CS should look like for shading patterns.

mkl-public commented 8 months ago

I still can't see where it says what the argument to cs and CS should look like for shading patterns.

See the entry for the CS operator in the same table:

The names DeviceGray, DeviceRGB, DeviceCMYK, and Pattern always identify the corresponding colour spaces directly; they never refer to resources in the ColorSpace subdictionary.

seehuhn commented 8 months ago

@mkl-public I don't think the sentence you quote is intended to say that all patterns use \Pattern CS. (For example uncoloured tiling patterns don't).

mkl-public commented 8 months ago

Correct. I also don't see a nice summary "For pattern type A set the pattern colorspace using X, for type B set it using Y, ...", just an example here and a reference there.

For colored patterns you have the example 1 in section 8.7.3.2:

If P1 is the name of a pattern resource in the current resource dictionary, the following code establishes it as the current nonstroking colour:

/Pattern cs
/P1 scn

For uncolored patterns you have the beginning of section 8.7.3.3:

A Pattern colour space representing an uncoloured tiling pattern shall have a parameter: an object identifying the underlying colour space in which the actual colour of the pattern shall be specified. The underlying colour space shall be given as the second element of the array that defines the Pattern colour space.

EXAMPLE 1 The array

[/Pattern /DeviceRGB]

defines a Pattern colour space with DeviceRGB as its underlying colour space.

NOTE The underlying colour space cannot be another Pattern colour space.

seehuhn commented 8 months ago

@mkl-public Thanks. I believe the spec does not explicitly give this information for shading patterns. Do you agree?

mkl-public commented 8 months ago

I believe the spec does not explicitly give this information for shading patterns. Do you agree?

At first glance I find none.