@@ -22,9 +22,9 @@ This file is part of the iText (R) project.
22
22
*/
23
23
package com .itextpdf .svg .utils ;
24
24
25
+ import com .itextpdf .commons .utils .MessageFormatUtil ;
25
26
import com .itextpdf .kernel .geom .AffineTransform ;
26
27
import com .itextpdf .styledxmlparser .css .util .CssDimensionParsingUtils ;
27
- import com .itextpdf .styledxmlparser .css .util .CssUtils ;
28
28
import com .itextpdf .svg .exceptions .SvgExceptionMessageConstant ;
29
29
import com .itextpdf .svg .exceptions .SvgProcessingException ;
30
30
@@ -200,7 +200,7 @@ private static AffineTransform createSkewYTransformation(List<String> values) {
200
200
throw new SvgProcessingException (SvgExceptionMessageConstant .TRANSFORM_INCORRECT_NUMBER_OF_VALUES );
201
201
}
202
202
203
- double tan = Math .tan (Math .toRadians (( float ) CssDimensionParsingUtils . parseFloat (values .get (0 ))));
203
+ double tan = Math .tan (Math .toRadians (parseTransformationValue (values .get (0 ))));
204
204
205
205
//Differs from the notation in the PDF-spec for skews
206
206
return new AffineTransform (1 , tan , 0 , 1 , 0 , 0 );
@@ -217,7 +217,7 @@ private static AffineTransform createSkewXTransformation(List<String> values) {
217
217
throw new SvgProcessingException (SvgExceptionMessageConstant .TRANSFORM_INCORRECT_NUMBER_OF_VALUES );
218
218
}
219
219
220
- double tan = Math .tan (Math .toRadians (( float ) CssDimensionParsingUtils . parseFloat (values .get (0 ))));
220
+ double tan = Math .tan (Math .toRadians (parseTransformationValue (values .get (0 ))));
221
221
222
222
//Differs from the notation in the PDF-spec for skews
223
223
return new AffineTransform (1 , 0 , tan , 1 , 0 , 0 );
@@ -234,7 +234,7 @@ private static AffineTransform createRotationTransformation(List<String> values)
234
234
throw new SvgProcessingException (SvgExceptionMessageConstant .TRANSFORM_INCORRECT_NUMBER_OF_VALUES );
235
235
}
236
236
237
- double angle = Math .toRadians (( float ) CssDimensionParsingUtils . parseFloat (values .get (0 )));
237
+ double angle = Math .toRadians (parseTransformationValue (values .get (0 )));
238
238
239
239
if (values .size () == 3 ) {
240
240
float centerX = CssDimensionParsingUtils .parseAbsoluteLength (values .get (1 ));
@@ -327,4 +327,14 @@ private static List<String> getValuesFromTransformationString(String transformat
327
327
328
328
return SvgCssUtils .splitValueList (numbers );
329
329
}
330
+
331
+ private static float parseTransformationValue (String valueStr ) {
332
+ Float valueParsed = CssDimensionParsingUtils .parseFloat (valueStr );
333
+ if (valueParsed == null ) {
334
+ throw new SvgProcessingException (MessageFormatUtil .format (
335
+ SvgExceptionMessageConstant .INVALID_TRANSFORM_VALUE , valueStr ));
336
+ } else {
337
+ return (float ) valueParsed ;
338
+ }
339
+ }
330
340
}
0 commit comments