在不同的 PDF 查看器中具有不同输出的 PDF(带有阴影)

A PDF with different outputs in different PDF viewers (with shades)

考虑以下 PostScript 文件

[1 0 0.5 0.866 150 550] concat
<< 
   /ShadingType 2 
   /Coords [ 0 0 100 100] 
   /BBox [ 0 0 100 100] 
   /ColorSpace [ /DeviceRGB ] 
   /Function 
      << 
         /FunctionType 0 
         /Domain [0 1] 
         /Range [0 1 0 1 0 1] 
         /BitsPerSample 8 
         /Size [2] 
         /DataSource <FFA0A0FFE0E0> 
      >>
   /Extend [false false] 
>> 
shfill

考虑一下我们使用 GhostScript (ps2pdf) 或 Adob​​e Distiller 将该文件转换为 PDF。

生成的 PDF 在不同的 PDF 查看器中呈现方式不同:

谁说得对?

我认为 Adob​​e Acrobat 是正确的,但也可以对规范进行不同的解读。

您的 PDF 包含以下内容流:

/GS1 gs
q
1 0 .5 .866 150 550 cm
/Sh1 sh
Q

即首先改变当前的变换矩阵,它被剪切和压扁一点,然后绘制阴影 Sh1。该阴影又定义为

<</BBox[0 0 100 100]/ColorSpace/DeviceRGB/Coords[0 0 100 100]/Function 15 0 R/ShadingType 2>>

即带有 100×100 方形边界框(解释为临时附加剪切路径)和沿其 (0, 0) 到 (100, 100) 对角线的轴向阴影,符合您的后记定义。

着色运算符sh指定为

Operands Operator Description
name sh (PDF 1.3) Paint the shape and colour shading described by a shading dictionary, subject to the current clipping path. The current colour in the graphics state is neither used nor altered. The effect is different from that of painting a path using a shading pattern as the current colour. name is the name of a shading dictionary resource in the Shading subdictionary of the current resource dictionary (see 7.8.3, "Resource dictionaries"). All coordinates in the shading dictionary are interpreted relative to the current user space. (By contrast, when a shading dictionary is used in a Type 2 pattern, the coordinates are expressed in pattern space.) All colours are interpreted in the colour space identified by the shading dictionary’s ColorSpace entry (see "Table 77 — Entries common to all shading dictionaries"). The Background entry, if present, is ignored.
This operator should be applied only to bounded or geometrically defined shadings. If applied to an unbounded shading, it paints the shading’s gradient fill across the entire clipping region, which may be time-consuming.

(ISO 32000-2:2017, Table 76 — 着色运算符)

特别是:着色字典中的所有坐标都相对于当前用户进行解释space。

因此,正方形边界框/临时剪辑路径被当前变换矩阵挤压并剪切成非矩形平行四边形,如在 Adob​​e Acrobat 中所示:

我在上面提到过规范也可以有不同的解读:如果将 BBox 条目视为两点的坐标,即左下角和右上角框,并在 before 中应用变换,使结果成为一个框,将得到一个被压扁的拉长矩形,如 Chrome:

中所示

但是这里的 BBox 被指定为 一个由四个数字组成的数组,分别给出了阴影边界的左、下、右和上坐标box (ibidem, Table 77 — 所有着色字典共有的条目) 而不是对角线两个端点的坐标。因此,我赞成同样由 Adob​​e 实现的第一种解释。

我还没有 ISO 32000-2:2020 的副本,所以也许这已经通过某种方式得到了澄清。


如果在填充指令期间将阴影用在本应用作当前颜色的图案中,情况会有所不同。在那种情况下,规范说:

A pattern’s appearance is described with respect to its own internal coordinate system. Every pattern has a pattern matrix, a transformation matrix that maps the pattern’s internal coordinate system to the default coordinate system of the pattern’s parent content stream (the content stream in which the pattern is defined as a resource). The concatenation of the pattern matrix with that of the parent content stream establishes the pattern coordinate space, within which all graphics objects in the pattern shall be interpreted.

(ISO 32000-2:2017,第 8.7.2 节 — 模式的一般属性)

在这种情况下,具有对角轴向阴影的方形边界框不会受到当前变换矩阵的影响。