PDF命令 - Q -Q是否保存路径?
我的pdf文件包含以下命令:
1.0 0 0 -1.0 0 810.0 cm
1.0 0 0 1.0 0 0 cm
1.0 0 0 1.0 9.0 9.0 cm
-9.0 -9.0 m 621.0 -9.0 l 621.0 801.0 l -9.0 801.0 l h
q
1.0 1.0 1.0 rg f
Q
q
1.0 0 0 1.0 0 0 cm
/Div <</MCID 0>> BDC
q
/GS_0-0-0-0x0 gs
q
q
q
1.0 0 0 1.0 -25.98 -17.82 cm
Q
q
1.0 0 0 1.0 -25.98 -17.82 cm
0 0 m 666.0 0 l 666.0 144.2 l 0 144.2 l h
q
.2392 .2784 .3215 rg f
Q
Q
Q
Q
Q
第4和20行中绘制矩形。在第6和22行中有一个填充命令“ f”
。第7行应将其归还。因此,第22行应该绘制两个矩形,但PDF观看器仅绘制一个矩形。我的问题是,哪个命令完全清除了第22行之前的第一个矩形?
My PDF file contains following commands:
1.0 0 0 -1.0 0 810.0 cm
1.0 0 0 1.0 0 0 cm
1.0 0 0 1.0 9.0 9.0 cm
-9.0 -9.0 m 621.0 -9.0 l 621.0 801.0 l -9.0 801.0 l h
q
1.0 1.0 1.0 rg f
Q
q
1.0 0 0 1.0 0 0 cm
/Div <</MCID 0>> BDC
q
/GS_0-0-0-0x0 gs
q
q
q
1.0 0 0 1.0 -25.98 -17.82 cm
Q
q
1.0 0 0 1.0 -25.98 -17.82 cm
0 0 m 666.0 0 l 666.0 144.2 l 0 144.2 l h
q
.2392 .2784 .3215 rg f
Q
Q
Q
Q
Q
A rectangle is drawn at lines 4 and 20. There is a fill command "f" at lines 6 and 22.
Calling "f" at line 6 clears the current vector path, however, "Q" on a line 7 should return it back. So the line 22 should paint two rectangles, but the PDF viewer draws only one rectangle. My question is, which command exactly clears the first rectangle before the line 22?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一方面,您可以看到 Q 不能通过研究规范来保存当前路径,因为Kens在他的评论。如果使用ISO Norm(ISO 32000-1或ISO 32000-2),则在8.4.1节中找到“独立于设备独立的图形状态参数”和“设备依赖的图形状态参数”的表。您会发现存储的唯一路径是剪辑路径。
但是您还可以看到, Q 不会考虑何时允许A Q 指令来保存当前的路径:您会特别发现在定义一条路径后,下一个指令后必须是路径绘画指令或剪裁路径指令,然后是路径绘画指令。因此,在下一个 Q 指令之前,已经使用(并因此被丢弃)路径!因此, Q 没有机会保存当前的路径。 (对于标准参考,请查看ISO 32000-1或ISO 32000-2中的图9 - 图形对象)。
顺便说一句,上面的第二段告诉您,您的示例无效, Q 也不是您在路径定义和路径绘画之间提供的 rg 指令。
因此,关于您的问题:
由于您的示例指令序列无效,因此结果不确定。但是,由于图形状态中的当前路径没有元素,因此特别是您不应该期望在 q 之后重新出现路径。
On one hand you can see that q does not save the current path by looking into the specification as KenS has proposed in his comment. If you use the ISO norm (either ISO 32000-1 or ISO 32000-2), you'll find the tables for "Device-Independent Graphics State Parameters" and "Device-Dependent Graphics State Parameters" in section 8.4.1. You'll see that the only path stored there is the clipping path.
But you can also see that q does not save the current path by considering when a q instruction is allowed: You'll find in particular that after defining a path the next instruction must be either a path painting instruction or or a clipping path instruction immediately followed by a path painting instruction. Thus, a path is already used (and, therefore, discarded) before the next q instruction! So q has no chance to save a current path. (For a normative reference have a look at Figure 9 – Graphics Objects – in ISO 32000-1 or ISO 32000-2).
As an aside, the second paragraph above tells you that your examples are invalid, neither the q nor the rg instructions you put between path definition and path painting are allowed.
So concerning your question:
As your example instruction sequence is invalid, the result is undefined. But as there is no element for the current path in the graphics state, you in particular should not expect the path to re-appear after Q.