PDF 着色类型 1基于函数和 FunctionType 4PostScriptt 计算器函数的简单示例

问题描述

我正在尝试使用 Type 1(基于函数)着色和 FunctionType 4(Postscript 计算器)为 PDF 着色编写自定义函数。 这是我尝试的基础:

...
5 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 500 400]
/Resources << /Shading << /Sh1 8 0 R  >> >>
/Contents 6 0 R
>>
endobj
6 0 obj  %Contents
<<
/Length 37
>>
stream
2 J
0 200 200 200 re
q
W n        %clip to 200x200 rectangle
/Sh1 sh    %fill with shading
Q
endstream
endobj
7 0 obj  %The function itself
<<
/FunctionType 4
/Domain [0 1 0 1]
/Range [0 1 0 1 0 1]
/Length 24
>>
stream
{
pop  %pop parameters - I guess these are x,y coordinates (?)
pop
0.5   %half red,green,blue = gray
0.5
0.5
}
endstream
endobj
8 0 obj       %The shading
<<
/ShadingType 1
/ColorSpace /DeviceRGB
/Function 7 0 R
>>
endobj
...

我认为这应该使正方形 200x200 变灰。 但结果什么都没有 - 画布保持空白(在 Adob​​e PDF 阅读器中尝试过)。

谁能告诉我我做错了什么?

或者-有人可以提供此类PDF的示例-具有自定义阴影功能吗? 我需要一些东西开始。 (稍后我想使用该功能为我的 SWF 到 PDF 转换器实现具有重复模式的径向着色)

我在互联网上没有找到任何与着色类型 1 相关的 PDF 示例。

解决方法

我现在发现了问题。

/FunctionType 4
/Domain [0 1 0 1]

我将函数域设置为 0-1,这会将坐标裁剪为最大值 1。 由于某些原因,我认为传入的坐标是 0-1。

修改

/FunctionType 4
/Domain [0 1000 0 1000]

对我有用,矩形是灰色的。