Skip to content

Commit bfd464d

Browse files
committed
TEST: saving PDF with simple draw commands
1 parent ab32889 commit bfd464d

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/tests/units/codecs-test-pdf.r3

+38-3
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ if find codecs 'pdf [
6969
]]
7070
)
7171
]
72-
--assert not error? try [save %tmp-empty.pdf pdf]
72+
--assert not error? try [save %tmp-empty.pdf empty-pdf]
7373
--assert object? try [p2: load %tmp-empty.pdf]
7474
--assert attempt [(keys-of empty-pdf/objects) = (keys-of p2/objects)]
7575
try [delete %tmp-empty.pdf]
7676

7777
--test-- "Save Simple Text PDF"
78-
pdf: copy/deep empty-pdf
78+
pdf: copy/deep/types empty-pdf any-type!
7979
; include text processing..
8080
append pdf/objects/4x0 'Text
8181
; include font
@@ -90,7 +90,7 @@ if find codecs 'pdf [
9090
; make some content
9191
pdf/objects/6x0/Data: {
9292
BT
93-
/F1 12 Tf 0 0 Td (0x0) Tj
93+
/F1 12 Tf 0 0 Td (0x0) Tj % left-bottom corner
9494
/F1 24 Tf 100 750 Td (Hello World) Tj
9595
ET
9696
}
@@ -99,7 +99,42 @@ if find codecs 'pdf [
9999
--assert attempt [(keys-of pdf/objects) = (keys-of p2/objects)]
100100
try [delete %tmp-text.pdf]
101101

102+
--test-- "Save Simple Draw PDF"
103+
pdf: copy/deep/types empty-pdf any-type!
104+
; make some content
105+
pdf/objects/6x0/Data: {
106+
% Draw black line segment, using the default line width.
107+
150 250 m
108+
150 350 l
109+
S
110+
111+
% Draw a thicker, dashed line segment.
112+
4 w % Set line width to 4 points.
113+
[4 6] 0 d % Set dash pattern.
114+
150 250 m
115+
400 250 l
116+
S
117+
118+
[] 0 d % Reset dash pattern to solid line.
119+
1 w % Reset line width to 1 unit.
102120
121+
% Draw a rectangle with 1-unit red border, filled with light blue.
122+
1.0 0.0 0.0 RG % Red for stroke color
123+
0.5 0.75 1.0 rg % Fill color
124+
200 300 50 75 re
125+
B
126+
127+
% Draw a curve filled with gray and with colored border.
128+
0.5 0.1 0.2 RG
129+
0.7 g
130+
300 300 m
131+
300 400 400 400 400 300 c
132+
b
133+
}
134+
--assert not error? try [save %tmp-draw.pdf pdf]
135+
--assert object? try [p2: load %tmp-draw.pdf]
136+
--assert attempt [(keys-of pdf/objects) = (keys-of p2/objects)]
137+
try [delete %tmp-draw.pdf]
103138
===end-group===
104139
]
105140

0 commit comments

Comments
 (0)