@@ -44,7 +44,9 @@ This file is part of the iText (R) project.
44
44
45
45
import com .itextpdf .html2pdf .attach .ProcessorContext ;
46
46
import com .itextpdf .html2pdf .css .CssConstants ;
47
+ import com .itextpdf .kernel .colors .Color ;
47
48
import com .itextpdf .kernel .colors .ColorConstants ;
49
+ import com .itextpdf .kernel .colors .DeviceCmyk ;
48
50
import com .itextpdf .kernel .colors .DeviceRgb ;
49
51
import com .itextpdf .layout .IPropertyContainer ;
50
52
import com .itextpdf .layout .borders .Border ;
@@ -58,6 +60,7 @@ This file is part of the iText (R) project.
58
60
import com .itextpdf .layout .borders .SolidBorder ;
59
61
import com .itextpdf .layout .properties .BorderRadius ;
60
62
import com .itextpdf .layout .properties .Property ;
63
+ import com .itextpdf .layout .properties .TransparentColor ;
61
64
import com .itextpdf .layout .properties .UnitValue ;
62
65
import com .itextpdf .styledxmlparser .css .resolve .CssDefaults ;
63
66
import com .itextpdf .styledxmlparser .css .util .CssDimensionParsingUtils ;
@@ -191,13 +194,13 @@ public static Border getCertainBorder(String borderWidth, String borderStyle, St
191
194
borderWidthValue = unitValue .getValue ();
192
195
Border border = null ;
193
196
if (borderWidthValue > 0 ) {
194
- DeviceRgb color = ( DeviceRgb ) ColorConstants .BLACK ;
197
+ Color color = ColorConstants .BLACK ;
195
198
float opacity = 1f ;
196
199
if (borderColor != null ) {
197
200
if (!CssConstants .TRANSPARENT .equals (borderColor )) {
198
- float [] rgbaColor = CssDimensionParsingUtils .parseRgbaColor (borderColor );
199
- color = new DeviceRgb ( rgbaColor [ 0 ], rgbaColor [ 1 ], rgbaColor [ 2 ] );
200
- opacity = rgbaColor [ 3 ] ;
201
+ TransparentColor tColor = CssDimensionParsingUtils .parseColor (borderColor );
202
+ color = tColor . getColor ( );
203
+ opacity = tColor . getOpacity () ;
201
204
} else {
202
205
opacity = 0f ;
203
206
}
@@ -219,16 +222,36 @@ public static Border getCertainBorder(String borderWidth, String borderStyle, St
219
222
border = new DoubleBorder (color , borderWidthValue , opacity );
220
223
break ;
221
224
case CssConstants .GROOVE :
222
- border = new GrooveBorder (color , borderWidthValue , opacity );
225
+ if (color instanceof DeviceRgb ) {
226
+ border = new GrooveBorder ((DeviceRgb )color , borderWidthValue , opacity );
227
+ }
228
+ if (color instanceof DeviceCmyk ) {
229
+ border = new GrooveBorder ((DeviceCmyk )color , borderWidthValue , opacity );
230
+ }
223
231
break ;
224
232
case CssConstants .RIDGE :
225
- border = new RidgeBorder (color , borderWidthValue , opacity );
233
+ if (color instanceof DeviceRgb ) {
234
+ border = new RidgeBorder ((DeviceRgb )color , borderWidthValue , opacity );
235
+ }
236
+ if (color instanceof DeviceCmyk ) {
237
+ border = new RidgeBorder ((DeviceCmyk )color , borderWidthValue , opacity );
238
+ }
226
239
break ;
227
240
case CssConstants .INSET :
228
- border = new InsetBorder (color , borderWidthValue , opacity );
241
+ if (color instanceof DeviceRgb ) {
242
+ border = new InsetBorder ((DeviceRgb )color , borderWidthValue , opacity );
243
+ }
244
+ if (color instanceof DeviceCmyk ) {
245
+ border = new InsetBorder ((DeviceCmyk )color , borderWidthValue , opacity );
246
+ }
229
247
break ;
230
248
case CssConstants .OUTSET :
231
- border = new OutsetBorder (color , borderWidthValue , opacity );
249
+ if (color instanceof DeviceRgb ) {
250
+ border = new OutsetBorder ((DeviceRgb )color , borderWidthValue , opacity );
251
+ }
252
+ if (color instanceof DeviceCmyk ) {
253
+ border = new OutsetBorder ((DeviceCmyk )color , borderWidthValue , opacity );
254
+ }
232
255
break ;
233
256
default :
234
257
border = null ;
0 commit comments