@@ -69,13 +69,13 @@ if find codecs 'pdf [
69
69
]]
70
70
)
71
71
]
72
- --assert not error? try [save %tmp-empty.pdf pdf]
72
+ --assert not error? try [save %tmp-empty.pdf empty- pdf]
73
73
--assert object? try [p2: load %tmp-empty.pdf ]
74
74
--assert attempt [(keys-of empty-pdf/objects ) = (keys-of p2/objects )]
75
75
try [delete %tmp-empty.pdf ]
76
76
77
77
--test-- "Save Simple Text PDF"
78
- pdf: copy/deep empty-pdf
78
+ pdf: copy/deep/types empty-pdf any-type!
79
79
; include text processing..
80
80
append pdf/objects/4x0 'Text
81
81
; include font
@@ -90,7 +90,7 @@ if find codecs 'pdf [
90
90
; make some content
91
91
pdf/objects/6x0/Data: {
92
92
BT
93
- /F1 12 Tf 0 0 Td (0x0) Tj
93
+ /F1 12 Tf 0 0 Td (0x0) Tj % left-bottom corner
94
94
/F1 24 Tf 100 750 Td (Hello World) Tj
95
95
ET
96
96
}
@@ -99,7 +99,42 @@ if find codecs 'pdf [
99
99
--assert attempt [(keys-of pdf/objects ) = (keys-of p2/objects )]
100
100
try [delete %tmp-text.pdf ]
101
101
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.
102
120
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 ]
103
138
===end-group===
104
139
]
105
140
0 commit comments