I have the following instructions in a deflate stream inside a PDF:
1 g
/GS1 gs
0 792 m
0 792 l
f
q
1 i
0 792 612 -792 re
0 792 m
W n
0 792.06 612 -792 re
W n
0
792
0
792
0
792
612
-792
rectangle subpath0
792
subpath.... Why would you override the previous rectangle path?0
792
subpath the clipping path and remove the current path.0
792.06
612
-792
rectangle.0
792
?The problem I have is that I didn't find good examples for how the clipping works. Which path do you clip against? What do you clip against if you didn't have a clipping path before?
Thanks!
First of all you are right to wonder, much in the excerpt you show makes no sense.
For example your items 3..5 concerning
0 792 m
0 792 l
f
The PDF specification states on filling paths like that:
If a subpath is degenerate (consists entirely of one or more points at the same coordinates), the subpath shall be considered to enclose the single device pixel lying under that point; the result is device-dependent and not generally useful.
(ISO 32000-2, section 8.5.3.3 — Filling)
Your interpretation of
0 792 612 -792 re
0 792 m
W n
in your items 8..10 is incorrect, though. In particular your assume the last line to
Make the 0 792 subpath the clipping path and remove the current path.
Actually the 0 792 m
subpath is disregarded and only the 0 792 612 -792 re
rectangle is intersected with the current clip path!
According to the specification clip path intersection works similar to filling
Subclause 8.5.3.3, "Filling" defines what is inside a path as well as stating rules for closing paths and for degenerate paths. For a given path definition, the same area that would be filled by the f operator is the area that would be used for a clip.
(ISO 32000-2, section 8.5.4 — Clipping path operators)
and filling would drop that dangling 0 792 m
.
Any subpaths that are open shall be implicitly closed before being filled, except that if the last subpath in the path is a single-point open subpath (specified by a trailing m operator), it shall be disregarded and not considered to be part of the path.
(ISO 32000-2, section 8.5.3.3 — Filling)
Thus your interpretation of
0 792.06 612 -792 re
W n
in your items 11 & 12
Clip the previous rectangle with the previous clipping path 0 792?
is slightly off: Actually this rectangle clips the previous clipping path last clipped by the other, nearly identical rectangle. But this hardly makes more sense to do than your original assumption would have.
Concerning your explicit question
Which path do you clip against? What do you clip against if you didn't have a clipping path before?
Here the specification says:
The initial clipping path shall include the entire page.
(ISO 32000-2, section 8.5.4 — Clipping path operators)